title: Handling a Shape by its Placeholder Name in PowerPoint
body: <p>I am attempting to create a function that will return a specific shape, based on the <em>known</em> Name property assigned to the <code>CustomLayout.Shapes.Placeholder</code> object.  I can't use the shape <code>.Name</code> because this is not known in advance, even when creating slides from template/layout.</p>
  
  <p>The challenge seems to be how the custom layout is related to the actual slide. For instance, when I iterate the slide's <code>.CustomLayout.Shapes.Placeholders</code>, I can easily identify the particular placeholder by it's <code>.Name</code> property.</p>
  
  <p><strong>HOWEVER</strong> if I return <em>this</em> shape, it will be the custom layout placeholder, which affects <strong>ALL</strong> slides on this layout (e.g., if I add text to this placeholder, it updates all slides using this layout!). Obviously this is undesirable!</p>
  
  <p>If instead, I index the collection, and attempt to return the shape at that index position, from the slide's <code>.Shapes.Placeholders</code>, it appears that they are not maintaining the same index, i.e., <code>.Shapes.Placeholders(i) &lt;&gt; .CustomLayout.Shapes.Placholders(i)</code></p>
  
  <p><strong>Attempted workaround:</strong></p>
  
  <p>Thought I might be able to manipulate the custom layout to add a <code>Tag</code> to the shapes. I tried, and it fails for the same reasons (i.e., the CustomLayout.Shape is somehow not the "same" shape as the Slide.Shape...). In any case, I'm hoping to avoid a "workaround" in favor of a more proper way to do this, if such a thing exists.</p>
  
  <p>This is the function I have so far:</p>
  
  <pre><code>Function GetShapeByPlaceholderName(sName As String, sld As Slide) As Object
  Dim plchldrs As Placeholders
  Dim shp As Shape
  Dim ret As Shape
  Dim i As Long
  
  For Each shp In sld.CustomLayout.Shapes.Placeholders
      i = i + 1
      If shp.Name = sName Then
      '#### 
      '    This can easily identify the CustomLayout.Shapes.PLACEHOLDER
      '
      '    But I need to return the SHAPE in the Slide.Shapes collection
      '####
  
          '###
          Set ret = shp  'This will return the CustomLayout.Placeholder, which affects ALL slides
  
          '###
          'Set ret = sld.Shapes.Placeholders(i) 'the index of the Shapes.Placeholders is NOT the same
  
          '###
          'Set ret = sld.Shapes.Placeholders.FindByName(sName) 'This returns an error/specified shape name does not exist
  
          '###
          'Set ret = sld.Shapes.Placeholders.FindByName(i) 'This observes same failure that the index of the collections is not the same
  
  
          Exit For
      End If
  Next
  
  Set GetShapeByPlaceholderName = ret
  
  End Function
  </code></pre>