PDA

View Full Version : [SOLVED:] Powerpoint macro to use shape text label to populate name shown in selection pane



Stampie
02-17-2019, 11:41 AM
I have a slide with over 230 rectangles (containing text labels, e.g. Marketing).


In the selection pane the rectangles all have names like 'Rectangle3'


To aid selection, I'm trying to come up with a macro to go through the rectangle text labels, and replace the corresponding selection pane name, e.g. Marketing >> Rectangle3 becomes Marketing >> Marketing


I'm pretty new to VBA in powerpoint and struggling to work this one out


I think I need to copy the 'label' attribute to the 'name' but not sure how to go about it

Any tips appreciated
thanks
Nick

John Wilson
02-18-2019, 07:36 AM
Not completely clear what you mean by TEXT LABEL" assuming you mean you added text to the shapes try this. Note this will modify ALL slides. For just the current slide (or selected slides)

Replace
For Each osld In ActivePresentation.Slides
With
For Each osld In ActiveWindow.Selection.SlideRange


Sub fixSelPane()
Dim osld As Slide
Dim oshp As Shape
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.HasTextFrame Then
If oshp.TextFrame.HasText Then
oshp.Name = oshp.TextFrame.TextRange
End If
End If
Next
Next
End Sub