Chart.Legend property (Project)

Gets an Office.IMsoLegend object that represents the legend for a chart. Read-only IMsoLegend.

Syntax

expression.Legend

expression A variable that represents a Chart object.

Example

The following example turns on the legend for the chart, and then sets the top of the legend 20 points lower than it was set previously.

Sub SetLegendTop()
    Dim chartShape As Shape
    Dim reportName As String
    Dim legendTop As Double
    
    reportName = "Simple scalar chart"
    Set chartShape = ActiveProject.Reports(reportName).Shapes(1)
    
    chartShape.Chart.HasLegend = True
    legendTop = chartShape.Chart.Legend.Top
    chartShape.Chart.Legend.Top = legendTop + 20
End Sub

Property value

IMSOLEGEND

See also

Chart Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.