如果知道Id
,有什么方法可以得到形状?
例如:
Dim myshape As Shape
myshape.Id = 42
myshape = getShapeById(myshape.Id)
或者,可以通过
Name
获得形状吗?Dim myshape As Shape
myshape.Name = "Rectangle 42"
myshape = getShapeByName(myshape.Name)
最佳答案
通过.Name
获取形状.Id
比getting its .Id
by its .Name
更加复杂。
但是,这是如何完成的:
Sub PrintShapeName()
Debug.Print getNameByID(3, 1)
End Sub
Function getNameByID(shapeID As Long, slide As Integer)
Dim ap As Presentation: Set ap = ActivePresentation
Dim sl As slide: Set sl = ap.Slides(slide)
sl.Shapes.SelectAll
Dim sr As ShapeRange
Set sr = Windows(1).Selection.ShapeRange
Dim s As Shape
For Each s In sr
If s.id = shapeID Then
getNameByID = s.Name
Exit Function
End If
Next
End Function
关于vba - 通过ID或名称获取形状,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5527073/