Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Prep4PDF preserves interactivity in PowerPoint presentations when you convert to PDF

The Name property of PowerPoint shapes is not reliable

Using the .Name property to get a reference to a shape on a slide, master, layout, notes page, etc. isn't entirely reliable and can lead to very odd results.

For example:

They're all named "Title 1".

PowerPoint seems to give you a reference to the first shape by that name if you use code like

ActivePresentation.Slides(1).Shapes("Title 1")

Different versions of PowerPoint may behave slightly differently, but on current versions it produces identically named shapes when you

If you insert a shape and don't change the name PowerPoint assigns it, PowerPoint will give it a new name when you copy the shape.

Solution

Rather than using a shape's .Name property, use its .ID. This function will return the shape with any given ID from a slide:

Function ShapeWithID(oSl As Slide, lID As Long) As Shape
' Returns a reference to the shape with ID lID
' on slide oSl (or Nothing)
    Dim oSh As Shape
    For Each oSh In oSl.Shapes
        Debug.Print oSh.Id
        If oSh.Id = lID Then
            Set ShapeWithID = oSh
            Exit Function
        End If
    Next
End Function

Use this to test the function:

Sub TestShapeWithID()
    Dim oSh As Shape
    ' Change the slide number and ID as needed:
    Set oSh = ShapeWithID(ActivePresentation.Slides(1), 9)
    If Not oSh Is Nothing Then
        oSh.Select
    End If
End Sub

Another approach is to use .Tags to identify slides or shapes that must be retrieved later. Learn more about using Tags in PowerPoint here:


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2015 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.
Español    Deutsch    Français    Português    Italiano    Nederlands    Greek    Japanese    Korean    Chinese

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

The Name property of PowerPoint shapes is not reliable
http://www.pptfaq.com/FAQ01218-The-Name-property-of-PowerPoint-shapes-is-not-reliable.htm
Last update 12 June, 2015
Created: 12 June, 2015