title: Set PowerPoint presentation when already opened (From Excel)
body: <p>I'm trying to open a specific powerpoint slide decided by the user in Excel. The code to open the Powerpoint to the specific slide is the following (targ is a string like <code>"Slide:12"</code>):</p>
  
  <pre><code>Function rcFollowSlide(targ As String)
      Dim PptPath As String
      Dim pptApp As PowerPoint.Application
      Dim pptPres As PowerPoint.Presentation
  
      targ = Mid(targ, InStr(targ, ":") + 1)
      targ = Left(targ, Len(targ) - 1)
      PptPath = wsSettings.Range("PPTPath").Value
  
      If IsPPTOpen(PptPath) Then
          MsgBox "Already opened"
          Exit Function
          'Set ppres =
      Else
          Set pptApp = CreateObject("Powerpoint.Application")
          Set pptPres = pptApp.Presentations.Open(PptPath)
      End If
  
      If targ &gt; 0 And targ &lt;= pptPres.Slides.Count Then
          pptPres.Slides(CInt(targ)).Select
      Else
          MsgBox "Image " &amp; targ &amp; " N/A."
      End If
  End Function
  </code></pre>
  
  <p>It works very well when the presentation is closed and it has to open it up. I'd like to set the Powerpoint presentation to pptPres when it's already opened as well, so I could get the code to continue running without opening a new instance of that presentation. How can I access the application in the first place, and set the presentation?    </p>
  
  <p>For reference, here is the function used to check if the PPT is already opened.</p>
  
  <pre><code>Function IsPPTOpen(FileName As String)
      Dim ff As Long, ErrNo As Long
  
      On Error Resume Next
      ff = FreeFile()
      Open FileName For Input Lock Read As #ff
      Close ff
      ErrNo = Err
      On Error GoTo 0
  
      Select Case ErrNo
      Case 0:    IsPPTOpen = False
      Case 70:   IsPPTOpen = True
      Case Else: Error ErrNo
      End Select
  End Function
  </code></pre>