Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I name objects in Powerpoint to reference in VBA code ?

Powerpoint

How can I name objects in Powerpoint to reference in VBA code ?

by  Chance1234  Posted    (Edited  )
Sub NameShape()
'used to name shapes
'select the shape by clicking on it then go to macros and and then run this code !!!!
'you can then use that name in VBA to reference that object. lot easier than trying to guess at "rectangle 2" or what index a object is.

Dim Name$
On Error GoTo AbortNameShape
If ActiveWindow.Selection.ShapeRange.Count = 0 Then
MsgBox "No Shapes Selected"
Exit Sub
End If
Name$ = ActiveWindow.Selection.ShapeRange(1).Name
Name$ = InputBox$("Give this shape a name", "Shape Name", Name$)
If Name$ <> "" Then
ActiveWindow.Selection.ShapeRange(1).Name = Name$
End If

Exit Sub

AbortNameShape:
MsgBox Err.Description

End Sub

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top