我在PowerPoint中有一个有很多形状的演示文稿。有没有办法命名所有形状的图形(仅从Excel工作簿链接)。例如,一张幻灯片有4个图形,因此形状的名称是MyPicture1,MyPicture2,MyPicture3和MyPicture4。到目前为止,代码看起来像
Sub test()
Dim lctr As Long
Dim shp As shape
Dim ii As Integer
For ii = 1 To 6
For Each shp In ActivePresentation.Slides(ii).Shapes
If shp.Type = msoChart Then
lctr = lctr + 1
shp.Name = "MyPicture" & lctr
End If
Next shp
Next ii
答案 0 :(得分:0)
如果我理解正确,您希望在演示文稿中列出所有图表的名称。为此,您可以使用单个循环,如:
Dim shp as Shape
For Each shp In ActivePresentation.Slides(i).Shapes
If shp.Type = msoChart Then
Debug.Print shp.Name
End If
Next
编辑:或者您也可以使用Shape.HasChart
属性。
If shp.HasChart Then
Debug.Print shp.Name
End If