Class LegendEntry (Word VBA)

The class LegendEntry represents a legend entry in a chart legend.

To use a LegendEntry class variable it first needs to be instantiated, for example

Dim lgne as LegendEntry
Set lgne = ActiveDocument.Background.Chart.Legend.LegendEntries(Index:=1)

LegendEntry class variables can be set using the LegendEntries.Item procedure.

For Each

Here is an example of processing the LegendEntry items in a collection.

Dim lgne As LegendEntry
For Each lgne In ActiveDocument.Background.Chart.Legend.LegendEntries()
Next lgne


Deletes the object.



Returns the font of the specified object.

Dim cftFont As ChartFont
Set cftFont = ActiveDocument.Background.Chart.Legend.LegendEntries(1).Font


Returns the line, fill, and effect formatting for the object.

Dim cftFormatted As ChartFormat
Set cftFormatted = ActiveDocument.Background.Chart.Legend.LegendEntries(1).Format


Returns the height, in points, of the object.

Dim dblHeight As Double
dblHeight = ActiveDocument.Background.Chart.Legend.LegendEntries(1).Height


Returns the index number of the object within the collection of similar objects.

Dim lngIndex As Long
lngIndex = ActiveDocument.Background.Chart.Legend.LegendEntries(1).Index


Returns the distance, in points, from the left edge of the object to the left edge of the chart area.

Dim dblLeft As Double
dblLeft = ActiveDocument.Background.Chart.Legend.LegendEntries(1).Left


Returns the legend key that is associated with the entry.

With ActiveDocument.InlineShapes(1) 
 If .HasChart Then 
 .Chart.Legend.LegendEntries(1).LegendKey _ 
 .MarkerStyle = xlMarkerStyleTriangle 
 End If 
End With


Selects the object.



Returns the distance, in points, from the top edge of the object to the top of the first row (on a worksheet) or the top of the chart area (on a chart).

Dim dblTop As Double
dblTop = ActiveDocument.Background.Chart.Legend.LegendEntries(1).Top


Returns the width, in points, of the object.

Dim dblWidth As Double
dblWidth = ActiveDocument.Background.Chart.Legend.LegendEntries(1).Width