Is there any way to get a shape if you know its Id?
For example:
Dim myshape As Shape
myshape.Id = 42
myshape = getShapeById(myshape.Id)
To get a Shape by Name, you do...:
Function getShapeByName(shapeName As String, Slide As Integer)
Set getShapeByName = ActivePresentation.Slides(Slide).Shapes(shapeName)
End Function
Dim myshape As Shape
myshape = getShapeByName("Rectangle 42", 1)
Getting a shape .Name by its .Id is somewhat more convoluted than getting its .Id by its .Name.
But here's how it's done:
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
sName = ActivePresentation.Slides(k).Shapes(j).Name
where k is the slide number and j and the shape number on that slide.
You can loop through each pages shapes with something like:
k = 1
For j = 1 To ActivePresentation.Slides(k).Shapes.Count
Next j
Chris
Not sure about by ID, but by name use the sheet Shapes collection object
Set myShape = <SheetObject>.Shapes("<ShapeName>")
eg
Set myShape = ActiveSheet.Shapes("Rectangle 1")