Free Macro To Select PowerPoint Shapes
Free Macro To Select PowerPoint Shapes
Free Macro To Select PowerPoint Shapes
Have you ever been frustrated when trying to select multiple shapes (or objects) on a PowerPoint slide?
Sometimes, it’s just because you have them overlapping on different layers and using the mouse to click is
tricky, often leading you to select things you don’t want.
Other times, it’s because you have many copies of a certain shape.
<img
class="aligncenter size-large wp-image-1620" alt="youpresent.co.uk - PowerPoint search and select macro -
slide A" src="http://www.youpresent.co.uk/wp-content/uploads/2013/09/i-present.co_.uk-PowerPoint-search-and-
select-macro-slide-A-1024x720.jpg" width="585" height="411" />
What a nightmare! Especially if the map below it is separate shapes (as they’d get selected too).
Firstly, you need to turn the PowerPoint Selection Pane on. To do this from the PowerPoint ribbon, click Home
/ Select / Selection Pane. Now we can see the names of all of our shapes on the slide over there on the right
hand side:
<img
class="aligncenter size-large wp-image-1621" alt="youpresent.co.uk - PowerPoint search and select macro -
slide B" src="http://www.youpresent.co.uk/wp-content/uploads/2013/09/i-present.co_.uk-PowerPoint-search-and-
select-macro-slide-B-1024x720.jpg" width="585" height="411" />
We can then see that all of the text labels include the common text “Label”. So let’s run our macro by pressing
Alt+F8, selecting it and clicking Run:
<img class="aligncenter size-full wp-image-
1618" alt="youpresent.co.uk - PowerPoint search and select macro - Alt+F8"
src="http://www.youpresent.co.uk/wp-content/uploads/2013/09/i-present.co_.uk-PowerPoint-search-and-select-
macro-Alt+F8.jpg" width="428" height="409" srcset="http://youpresent.co.uk/wp-content/uploads/2013/09/i-
present.co_.uk-PowerPoint-search-and-select-macro-Alt+F8.jpg 428w, http://youpresent.co.uk/wp-
content/uploads/2013/09/i-present.co_.uk-PowerPoint-search-and-select-macro-Alt+F8-300x286.jpg 300w"
sizes="(max-width: 428px) 100vw, 428px" />
We’re first asked to enter the text we want to search for within the name of each shape on the current slide:
Once we’ve entered our search text, we click OK and in the blink of an eye (yes, really)…
<img class="aligncenter size-full wp-image-
1619" alt="youpresent.co.uk - PowerPoint search and select macro - result"
src="http://www.youpresent.co.uk/wp-content/uploads/2013/09/i-present.co_.uk-PowerPoint-search-and-select-
macro-result.jpg" width="414" height="202" srcset="http://youpresent.co.uk/wp-content/uploads/2013/09/i-
present.co_.uk-PowerPoint-search-and-select-macro-result.jpg 414w, http://youpresent.co.uk/wp-
content/uploads/2013/09/i-present.co_.uk-PowerPoint-search-and-select-macro-result-300x146.jpg 300w"
sizes="(max-width: 414px) 100vw, 414px" />
And hey presto, all our shapes that include the text “label” within their names are selected on the slide:
<img
class="aligncenter size-large wp-image-1622" alt="youpresent.co.uk - PowerPoint search and select macro -
slide C" src="http://www.youpresent.co.uk/wp-content/uploads/2013/09/i-present.co_.uk-PowerPoint-search-
and-select-macro-slide-C-1024x714.jpg" width="585" height="407" />
Note that the text box on the top left has also been selected so we can remove that from my selection either by
using the Selection Pane and while holding the Ctrl key, clicking it’s name or, we can again hold the Ctrl key
while clicking the unwanted shape on the slide.
Now that everything is selected, I could group it all for future use and then modify it’s style such as font size, fill
color, glow etc.
This code is contained within a presentation but it could be a permanent button in the ribbon if we built it into an
add-in. If you need custom macro code or an add-in developed to make your presentation day more productive,
contact us now.
Contact Us Now!
Tip: You can select a shape on the slide and use it’s name as the shape to search for.
'
================================================================================
' Procedure to find and select similarly named shapes on a selected slide
' This means you must give credit for our original creation in the following form:
' "Includes code created by YOUpresent Ltd. (youpresent.co.uk)"
'
================================================================================
' One or more shapes are selected, check if the user wants to retain the selection and set the counter if
yes
Case ppSelectionShapes
response = MsgBox("There are one or more shapes selected already." & Chr(13) & Chr(13) & _
Case vbYes
counter = ActiveWindow.Selection.ShapeRange.Count
Case vbNo
shapeName = ActiveWindow.Selection.ShapeRange(1).Name
' To automatically search, we need to find the first part of the shape name
' as PowerPoint shapes are named by default using the form "rectangle 123"
' If we found a space, set the search string to the first word of the name
Else
search = shapeName
End If
' If we've extracted a search string then skip past asking the user for one
Case vbCancel
ActiveWindow.Selection.Unselect
End Select
' One or more slides are selected, warn if more than one is selected
Case ppSelectionSlides
Exit Sub
End If
' Nothing is selected so remind the user that a slide must be selected first
Case ppSelectionNone
' Check that a slide is in view, if not, an error will occur which we can handle
curSlide = ActiveWindow.View.slide.SlideIndex
MsgBox "Please select a slide first!", vbCritical + vbOKOnly, "No slide selected"
Exit Sub
End If
Case ppSelectionText
ActiveWindow.Selection.Unselect
End Select
' Ask the user what to search for
search = InputBox("Enter text to search for in your shape names" & Chr(13) & Chr(13) & _
skipSearchInput:
curSlide = ActiveWindow.View.slide.SlideIndex
' Search through all shapes on the slide, looking for the user entered string
oShp.Select msoFalse
counter = counter + 1
End If
Next
Case 0
MsgBox "Search : " & search & Chr(13) & Chr(13) & _
Case 1
MsgBox "Search : " & search & Chr(13) & Chr(13) & _
counter & " shape was found and is selected on your slide.", _
Case Else
MsgBox "Search : " & search & Chr(13) & Chr(13) & _
counter & " shapes were found and are selected on your slide.", _
End Select
End Sub
Submit a Comment