PPT7: OLE Automation Error Using Open Method

Last reviewed: March 6, 1998
Article ID: Q155073

The information in this article applies to:

Microsoft PowerPoint for Windows 95, version 7.0

SYMPTOMS

If you try to use a Microsoft Excel or Word macro, or another Visual Basic for Applications procedure to open a PowerPoint 95 presentation, you may receive the following error message:

   Runtime Error: '-2147188160 (80048240)':
   Presentation.Open invalid request.  The PowerPoint Frame Window does
   not exist.

CAUSE

This error will occur if you use the Application.Presentations.Open method before showing the PowerPoint application window at least once. A simple example of code that will produce this error follows:

   Private Sub Form_Load()
      Dim ppt As Object
      Dim pres As Object
      Set ppt = CreateObject("PowerPoint.application.7")
      Set pres = ppt.presentations.open("c:\windows\desktop\test.ppt")
   End Sub

The error will occur at the "Set Pres..." line.

RESOLUTION

Microsoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.

To work around this problem, use the following steps to modify the macro:

  1. Locate the "Set ppt" and the "Set pres" lines.

  2. Position the insertion point after the "Set ppt" line, but before the "Set pres" line.

  3. Add the following line in the macro:

        ppt.AppWindow.Visible = True
    

    The edited macro should resemble the following:

          Private Sub Form_Load()
    
             Dim ppt As Object
             Dim pres As Object
    
            Set ppt = CreateObject("PowerPoint.application.7")
            ppt.AppWindow.Visible = True
            Set pres = ppt.presentations.open("c:\windows\desktop\test.ppt")
          End Sub
    
    
If you want PowerPoint to be essentially invisible, you can use the following command to minimizePowerPoint's application window before opening the presentation file:

   ppt.AppWindow.Windowstate = ppWindowMinimized

This line must come after the "ppt.AppWindow.Visible" command, otherwise the window will not be minimized. The code might look something like the following:

   Private Sub Form_Load()
      Dim ppt As Object
      Dim pres As Object

      Set ppt = CreateObject("PowerPoint.application.7")
      ppt.AppWindow.Visible = True
      ppt.AppWindow.Windowstate = ppWindowMinimized
      Set pres = ppt.presentations.open("c:\windows\desktop\test.ppt")
   End Sub

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


Additional query words: VBA Access Excel PowerPoint VB powernt

Keywords : kbcode kbmacro kbprg kbdta kbdtacode kbpptvba
Version : WINDOWS:7.0
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 6, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.