Get form id by name

Is there a way to get a form Idif you know it Name?

For example, if I have this:

Dim myshape As Shape
myshape.Name

Can i get it Id?

myshape.Id = getIdByName(myshape.Name)
+3
source share
1 answer

Of course, this is pretty tricky:

Sub PrintShapeID()
    Debug.Print getIDByName("My Shape", 1)
End Sub

Function getIDByName(shapeName As String, slide As Integer)
    Dim ap As Presentation: Set ap = ActivePresentation
    Dim sl As slide: Set sl = ap.Slides(slide)
    Dim sh As Shape: Set sh = sl.Shapes(shapeName)
    getIDByName = sh.Id
End Function

This works for the selected slide. You can also scroll through all the slides, but note that there can be more than one shape with the same name, so you need to find out which one you want.

+4
source

Source: https://habr.com/ru/post/1695169/


All Articles