Jay Hayers
Jay Hayers

Reputation: 47

How to select multiple shapes by name in PowerPoint VBA?

For Each Shape In Slide.Shapes With Slide.Shapes("BOXNAME")

Selects the box named BOXNAME how would I select multiple shapes by name at once?

Upvotes: 1

Views: 1688

Answers (2)

John Korchok
John Korchok

Reputation: 4913

If the shapes are grouped, you can select them all simultaneously by selecting the group:

ActiveWindow.Selection.SlideRange.Shapes("Group 7").Select

Otherwise, you can create an array of shape names, then select the array:

ActiveWindow.Selection.SlideRange.Shapes.Range(Array("Oval 6", "Rectangle 4", "AutoShape 5")).Select

Upvotes: 5

Kusa Shaha
Kusa Shaha

Reputation: 112

I would suggest having the shapes to be named as BOXNAME1, BOXNAME2, ...

If i = 1 To 10
With Slide.Shapes("BOXNAME" & i)
On Error Resume Next
End With

This will condense multiple sub-routines into a single sub-routine.

Upvotes: 0

Related Questions