Presentations.Open requires PowerPoint 2007 to be open?

976 views Asked by At

I have a macro runTest in a PowerPoint file test.pptm that I wish to call by using the following VB script. All works well when the script is called on a machine with Office 2010, but the script will only work with Office 2007 providing the PowerPoint application has been opened before calling the script. I'd be interested to hear whether anyone has experienced a similar problem, or to hear of any potential solutions.

Option Explicit
On Error Resume Next

RunProcess

Sub RunProcess() 

    Dim pptApp 
    Dim pptPresentation 
    Set pptApp = CreateObject("PowerPoint.Application") 
    Set pptPresentation = pptApp.Presentations.Open("C:\test.pptm", True) 
    pptApp.Run "test.pptm!runTest"
    pptApp.Quit 
    Set pptPresentation = Nothing 
    Set pptApp = Nothing 

 End Sub 
2

There are 2 answers

0
ServerGuy On

In the event that it needs Powerpoint launched, I would just trigger the launch as part of the vbscript

Set WshShell = wscript.CreateObject("wscript.Shell")
WshShell.Run "C:\Program Files (x86)\Microsoft Office\Office12\POWERPNT.EXE"

You could build in some error handling to see which version is installed, and call the appropriate exe file

0
Franzl On

I resolved the problem by adding

    pptApp.Visible = True

after creating pptApp and before opening the presentation.