DrS.
DrS.

Reputation: 67

vba get id of selected shape

I am trying to get the id of a selected group-shape after I have just grouped it. But I can't find the right syntax. Many thanks for your help. Here is my current code

Dim Ausgabe as Integer
[...]
        If ActiveWindow.Selection.ShapeRange.count > 1 Then
            ActiveWindow.Selection.ShapeRange.Group.Select
            'Ausgabe = .Shape.Id --> This line does not work ...
            MsgBox (Ausgabe)
        Else
[...]

Many thanks for your help.

Upvotes: 0

Views: 4602

Answers (1)

Bond
Bond

Reputation: 16321

If you have a group of shapes selected, you can iterate the GroupItems property to get each Shape object and its properties:

Dim sh As Shape
For Each sh In ActiveWindow.Selection.ShapeRange.GroupItems
    MsgBox "Shape name: " & sh.Name & ", ID: " & sh.Id
Next

Upvotes: 1

Related Questions