Log in

View Full Version : Remove Data Labels



balumail75
11-03-2011, 10:30 PM
Hello all,

I am writing vba code for removing data labels for the charts type 100% stacked bar in ppt 2007. Below is the code, I have created. This gives the error message "This member can only be accessed for a chart object". Please help in this code.



Dim sld As Slide
Dim shp As Shape

For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasChart And shp.Chart.ChartType = 59 Then
shp.Chart.ApplyDataLabels xlDataLabelsShowNone
End If

Next shp
Next sld

John Wilson
11-03-2011, 11:06 PM
I suspect this line is the problem

If shp.HasChart And shp.Chart.ChartType = 59 Then
The And shp.ChartType is being checked even if hasChart is false and giving an error.

Try

If shp.HasChart Then
If shp.Chart.ChartType = 59 Then

balumail75
11-05-2011, 07:45 AM
Thanks John, It's working.