Hi
I have a macro that I created from Googling that adds a data label to the last data point in each series in an Excel chart. It works well (except the last data point has to be the same for each series, if one series say has more data points than the rest, only the series will be labelled).
Anyway, I wish to use the same macro in PowerPoint, to do the same thing to charts embedded in a particular slide, however, it seems the reference to ActiveChart doesn't work.
Can anyone help? I don't want it to iterate through all the charts in a presentation, just the currently selected one.
This is for PowerPoint 2007.
I have a macro that I created from Googling that adds a data label to the last data point in each series in an Excel chart. It works well (except the last data point has to be the same for each series, if one series say has more data points than the rest, only the series will be labelled).
Anyway, I wish to use the same macro in PowerPoint, to do the same thing to charts embedded in a particular slide, however, it seems the reference to ActiveChart doesn't work.
Can anyone help? I don't want it to iterate through all the charts in a presentation, just the currently selected one.
Code:
Option Explicit
Sub LastPointLabel()
Dim mySrs As Series
Dim nPts As Long
If ActiveChart Is Nothing Then
MsgBox "Please select a chart and try again.", vbExclamation
Else
For Each mySrs In ActiveChart.SeriesCollection
With mySrs
nPts = .Points.Count
mySrs.Points(nPts).ApplyDataLabels _
Type:=xlDataLabelsShowValue, _
AutoText:=True, LegendKey:=False
mySrs.Points(nPts).DataLabel.ShowValue = True
End With
Next
End If
End Sub
This is for PowerPoint 2007.