title: Applescript - Creating a new slide in a PowerPoint presentation fails because it doesn't load fast enough
body: <p>Here is a sample AppleScript I have:</p>
  
  <pre><code>tell application "Microsoft PowerPoint"
      activate
      if active presentation exists then
      else
          make new presentation
      end if
      set newSlide to make new slide at the end of active presentation
      make new picture at newSlide with properties {file name:"blahblahHFSfilepath", height:100, width:100, lock aspect ratio:true}
  end tell
  </code></pre>
  
  <p>This works-- but ONLY if PowerPoint is already open.  If it isn't open, this script opens up PowerPoint, and creates a new presentation.  Then it tries creating a new slide, but because when PowerPoint first loads the presentation isn't created yet, there is an error that occurs.  I concluded this to be the problem because if I put a <code>delay 1</code> after the <code>make new presentation</code> line, it will work.</p>
  
  <p>Is there a way I can determine IF the presentation is done being created, THEN make the new slide?  Or would a delay in this case be the best route?  My concern is that an older machine may take significantly longer to create a presentation.  </p>
  
  <p>To me, I think I just need to have something like a "wait until new presentation is created, and THEN create new slide"  But I can't figure out how to do so.</p>
  
  <p>Any AppleScripters out there know an easy solution?</p>
  
  <p>Thanks!</p>