Microsoft Office Tutorials and References
In Depth Information
DETERMINE THE HEIGHT AND WIDTH OF THE DATALABEL OBJECT
Sub FindLblSize()
Dim Lbl As DataLabel
Set Cht = ActiveChart
Set Lbl = Cht.SeriesCollection(1).Points(3).DataLabel
‘Get height and width of the chart area
ChartWd = Cht.ChartArea.Width
ChartHt = Cht.ChartArea.Height
‘Store old position of data label
OldTop = Lbl.Top
OldLeft = Lbl.Left
‘Attempt to move data label so that top left corner
‘coincides with bottom right corner of chart area
Lbl.Top = ChartHt
Lbl.Left = ChartWd
‘Above move makes bottom right corner of data label
‘to coincide with bottom right corner of chart area
‘as it cannot be moved any further
‘Calculate and display the label dimensions
LblWd = ChartWd - Lbl.Left
LblHt = ChartHt - Lbl.Top
MsgBox "Label dimensions: Width = " & LblWd & " Height
= " & LblHt
‘Restore label to a slightly staggered position to remove
overlap
Lbl.Left = OldLeft
Lbl.Top = Cht.SeriesCollection(1).Points(2).DataLabel.Top -
LblHt
End Sub
Part
2
With the background discussed earlier, the comments in the code are self-
explanatory. Figure 87 shows the chart after the label’s position has been
adjusted
 
Search JabSto ::




Custom Search