title: Positioning images on slides in PowerPoint 2007 using vba
body: <p>I'd like to do one of two things in PowerPoint 2007 on Windows. </p>
  
  <p>The first is to change the default location for pasting in an image. When I paste in a graph I made with SAS, it pastes into the upper lefthand corner. Ideally, I'd like to change the default paste position. There don't seem to be any simple options for this but I thought maybe it was possible with VBA.</p>
  
  <p>If it's not possible, then I'd like to write a VBA macro to step through each slide and change the image position.</p>
  
  <p>I got a slide loop to work, thanks to this and other sites (the MsgBox is just a test):</p>
  
  <pre><code>Sub SlideLoop()
      Dim osld As Slide
  
      For Each osld In ActivePresentation.Slides
          osld.Select
          MsgBox "The slide index of the current slide is: " &amp; _
               ActiveWindow.View.Slide.SlideIndex
      Next osld
  
  End Sub
  </code></pre>
  
  <p>Beyond that, I haven't had much luck. I have seen code snippets that select all images on a slide and crop or resize them, and I found this bit on excelhelphq.com that is meant to position an image:</p>
  
  <pre><code>With ActiveWindow.Selection.ShapeRange
    .Left = 50 'change the number for desired x position
    .Top = 50 'change the number for desired y position
  End With 
  </code></pre>
  
  <p>But I'm not sure how to integrate it into the loop, and the online documentation for Powerpoint VBA is not particularly robust. Some code deals with the ShapeIndex but I wasn't sure how to work with that.</p>
  
  <p>I should mention that I have only one image on a slide when I have an image (some slides do not have images at all, though). </p>
  
  <p>This seems like the best time-saving approach, though I'm still manually pasting into PowerPoint in the first place. </p>
  
  <p>I appreciate any help with this! I couldn't find anything that addressed this exact question.</p>
  
  <p>Is VBA for PPT being phased out? It feels like Microsoft doesn't want people to be able to figure out how to use it based on their not-stellar online documentation. </p>