How to name an object within a PowerPoint slide?

VbaPowerpoint

Vba Problem Overview


So I know how to name a textbox, or a like object in PowerPoint with VB, but I was wondering if there was a way to name objects through the Ribbon (PowerPoint 2007). For instance, if I add a text box onto a slide, is there a way to assign it a name (sort of like the properties window in access, or the textbox in Excel 2003 at the top left side where you can enter the name)?

Basically so I can reference it in code later; without having to use code to name each and every object i add after the fact. Perhaps an easier way through the Ribbon?

Vba Solutions


Solution 1 - Vba

PowerPoint for Windows:

  1. Click on the object (textbox, shape, etc.) to select it.
  2. In the Drawing Tools | Format tab, click on Selection Pane in the Arrange group.
  3. From there, you'll see names of objects.
  4. Double click (or press F2) on any name and rename it. By deselecting it, it becomes renamed.

You can also get to this from the Home tab -> Drawing group -> Arrange drop-down -> Selection pane or by pressing ALT + F10.

Solution 2 - Vba

Select the Object -> Format -> Selection Pane -> Double click to change the name

enter image description here

Solution 3 - Vba

While the answer above is correct I would not recommend you to change the name in order to rely on it in the code.

Names are tricky. They can change. You should use the ShapeId and SlideId.

Especially beware to change the name of a shape programmatically since PowerPoint relies on the name and it might hinder its regular operation.

Solution 4 - Vba

THIS IS NOT AN ANSWER TO THE ORIGINAL QUESTION, IT'S AN ANSWER TO @Teddy's QUESTION IN @Dudi's ANSWER'S COMMENTS

Here's a way to list id's in the active presentation to the immediate window (Ctrl + G) in VBA editor:

Sub ListAllShapes()

    Dim curSlide As Slide
    Dim curShape As Shape

    For Each curSlide In ActivePresentation.Slides
        Debug.Print curSlide.SlideID
        For Each curShape In curSlide.Shapes
            
                If curShape.TextFrame.HasText Then
                    Debug.Print curShape.Id
                End If
                
        Next curShape
    Next curSlide
End Sub

Solution 5 - Vba

Click Insert ->Object->Create from file ->Browse.

Once the file is selected choose the "Change icon" option and you will be able to rename the file and change the icon if you wish.

Hope this helps!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJustinView Question on Stackoverflow
Solution 1 - VbaTodd MainView Answer on Stackoverflow
Solution 2 - VbaBhanu SinhaView Answer on Stackoverflow
Solution 3 - VbaDudiView Answer on Stackoverflow
Solution 4 - VbaHauns TMView Answer on Stackoverflow
Solution 5 - VbaShaView Answer on Stackoverflow