title: Open powerpoint with vb.net, leave open and how to release objects when powerpoint is closed?
body: <p>I have the following code to run a macro in a powerpoint file via VB.NET 2013 Express:</p>
  
  <pre><code>        'Start PowerPoint and open the presentation.
          Dim oPP = New Microsoft.Office.Interop.PowerPoint.Application()
          oPP.Visible = MsoTriState.msoTrue
          Dim oPresSet = oPP.Presentations
          Dim oPres = oPresSet.Open(PFile)
          oPP.Run("'Plan.ppt'!UpdatePlan")
          oPres = Nothing
          If Not oPresSet Is Nothing Then
              System.Runtime.InteropServices.Marshal.ReleaseComObject(oPresSet)
              oPresSet = Nothing
          End If
          oPP.Quit()
          If Not oPP Is Nothing Then
              System.Runtime.InteropServices.Marshal.ReleaseComObject(oPP)
              oPP = Nothing
          End If
  </code></pre>
  
  <p>I leave the powerpoint open to view and then close the file via powerpoint. When this code is run the code again, I get the following error with the following line of code:</p>
  
  <pre><code>        Dim oPP = New Microsoft.Office.Interop.PowerPoint.Application()
  </code></pre>
  
  <p>Error Message - "An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Plan.exe</p>
  
  <p>Additional information: Creating an instance of the COM component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} from the IClassFactory failed due to the following error: 800706b5."</p>
  
  <p>Is there any way to release the objects when powerpoint file is closed via powerpoint so that I can re-run the code again without error?</p>
  
  <p>Is there another way to do this so that I don't get these errors?</p>
  
  <p>Been working on this for ages and help would be much appreciated. Thanks.</p>