title: PowerPoint Interop: Get Placeholder by Name defined in Master
body: <p>In my PowerPoint AddIn I want to access shapes on the slides. The shapes are placeholders defined in custom layouts in the slidemaster.</p>
  
  <p>When I add a slide based on the custom layout, the shapes just get named "placeholder 1", "placeholder 2", ...</p>
  
  <p>Is there a way to get the placeholder by the name given in the master?</p>
  
  <p>Currently I am searching shapes with this code:</p>
  
  <pre><code>public static Shape GetShape(string stringToSearch, Shapes shapes) {
  
          foreach (Shape shape in shapes) {
  
              if (shape.Name == stringToSearch) {
                  return shape;
              }
  
              // Search Groups
              if (shape.Type == MsoShapeType.msoGroup) {
                  foreach (Shape childshape in shape.GroupItems) {
                      if (childshape.Name == stringToSearch) {
                          return childshape;
                      }
                  }
              }
          }
  
          throw new KeyNotFoundException("No Shape found");
  }
  </code></pre>
  
  <hr>
  
  <p>Update: 
  Maybe to make it more clear, this is the structure of the PowerPoint-Presentation.</p>
  
  <p>Master with Names defined for placeholders:
  <img src="https://i.stack.imgur.com/zPWdc.png" alt="Scrennshot of the master"></p>
  
  <p>Presentation where names defined in master are lost:
  <img src="https://i.stack.imgur.com/A7Wny.png" alt="Screenshot of the presentation"></p>
  
  <p>Problem: How to get element in presentation, by name defined in master?</p>