Microsoft KB Archive/155073

= PPT7: OLE Automation Error Using Open Method =

Article ID: 155073

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft PowerPoint 95 Standard Edition

-



This article was previously published under Q155073



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:  Locate the "Set ppt" and the "Set pres" lines. Position the insertion point after the "Set ppt" line, but before the "Set pres" line.  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 kbdtacode kberrmsg kbhowto kbmacro kbprogramming KB155073

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.