Open PPT with Excel

E

Erin

I am ready to throw my laptop out the window, so please
help!

I have looked around at various websites and found the
following code for opening a PPT file from an Excel macro:

Dim PPApp as PowerPoint.Application
Dim PPPres as PowerPoint.Presentation
Set PPApp = CreateObject ("Powerpoint.Application.9")
Set PPPres = PPApp.Presentations.Open ("Filename")

I get the following error:
Presentations (unknown member): Invalid request. The
PowerPoint Frame window does not exist.

This code does work if I already have an instance of
PowerPoint open (it still does not create a new instance).

Why! Why! I am using Office 2K on Windows 2K Pro.

Thank you

Erin
 
P

PPTMagician

Hi Erin,

Maybe this is too simplistic, but you can you skip the VBA and just open the
show with a link? If you save the presentation as a PPS file, it should
play automatically.

HTH,
Glenna
 
E

Erin

Thanks. That is a good thought, unfortunately not at all
what I'm doing. I should have been more clear.

I have a drop box in Excel where users can select what
region they want the PowerPoint presentation to cover. By
selecting from the list, Excel does a whole lot of
calculations, puts the selected data into the source data
for charts that are linked to PPT, then is supposed to
open the linked PPT, refresh the links and bring up the
Save As dialogue box.

Because the end users vary from computer whiz to "there's
2 buttons on the mouse???" this needs to be completely
automated.

Thanks for any suggestions!

Erin
 
B

Brian Reilly, MS MVP

Erin,
You are missing the code to create the PPT object.

Here's a sample function I have used in the past. The variables are
declared elsewhere like you have done in your sample code.

Function Start_PPT_File()
Set oPPt = CreateObject("PowerPoint.Application")
oPPt.Visible = True
oPPt.presentations.Open FileName:=(CDPath & "\Data\" & strPPTLogo &
".ppt"), ReadOnly:=msoFalse
oPPt.ActiveWindow.ViewType = 7
End Function

Brian Reilly, PowerPoint MVP
 
S

Steve Rindsberg

I am ready to throw my laptop out the window, so please
help!

I have looked around at various websites and found the
following code for opening a PPT file from an Excel macro:

Dim PPApp as PowerPoint.Application
Dim PPPres as PowerPoint.Presentation
Set PPApp = CreateObject ("Powerpoint.Application.9")
Set PPPres = PPApp.Presentations.Open ("Filename")

I get the following error:
Presentations (unknown member): Invalid request. The
PowerPoint Frame window does not exist.

Here's another example (from an Excel macro that controls PowerPoint, as it
happens, but it doesn't really matter).

I can see two problems with your code right off:

Presentations.Open ("Filename") won't work. Substitute the full path to a file
for Filename or change the code to use a variable that's set to the full path
to a file as below. I suspect you know this already and just wrote it this way
as an example. ;-)

The biggie is that you have to make ppt visible. I suspect that's the real
cause of your problems.


Sub AutomatePowerPoint()
' This requires that you set a reference to PowerPoint in Tools, References
' You could later change these to As Object to avoid that necessity
Dim oPPTApp As PowerPoint.Application
Dim oPPTPres As PowerPoint.Presentation
Dim sPresentationFile as String

sPresentationFile = "C:\MyFiles\Somefile.PPT"

' Get a reference to PowerPoint app
Set oPPTApp = New PowerPoint.Application
' MUST set it visible or you get errors
oPPTApp.Visible = True
' minimize if you want to hide it:
' oPPTApp.WindowState = ppWindowMinimized

' Open our source PPT file, get a reference to it
Set oPPTPres = oPPTApp.Presentations.Open(sPresentationFile)

With oPPTPres ' Do stuff ...
' Show the number of slides in the file, for example
msgbox .Slides.Count
End With

' Cleanup
' Close the presentation
oPPTPres.Close
' Quit PPT
oPPTApp.Quit
' Release variables
Set oPPTPres = Nothing
Set oPPTApp = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top