我试图使用此代码段设置数据点的数据标签属性,但由于某些原因,这些属性没有按预期设置。为了更清晰起见,请看图。
解决方法可能是使用Reset label Text (参见Pic -2),从而强制数据标签更新set属性。但我找不到与之相当的vba。帮助。
'This is happening inside a loop
Dim thisbarpoint As Point
Set thisbarpoint = thischart.FullSeriesCollection(ibar).Points(jbar)
thisbarpoint.DataLabel.ShowCategoryName = True
thisbarpoint.DataLabel.ShowValue = False
thisbarpoint.DataLabel.ShowSeriesName = False
Debug.Print thisbarpoint.DataLabel.caption
Dim DataLabelCaption As String
DataLabelCaption = thisbarpoint.DataLabel.caption
Debug.Print DataLabelCaption 'This gives the value as 26.7%PIC-1:

PIC-2:

发布于 2021-12-21 07:01:33
这对我来说很好:
Dim cht As Chart, s As Series
Set cht = ActivePresentation.Slides(1).Shapes(1).Chart
Set s = cht.SeriesCollection(1)
Debug.Print s.HasDataLabels 'False
s.HasDataLabels = True
With s.DataLabels
.ShowCategoryName = True
.ShowValue = False
.ShowSeriesName = False
End With我们无法知道您的文件是否已损坏,或者您未包括的代码中是否存在问题。
https://stackoverflow.com/questions/70431154
复制相似问题