View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default Creating new Powerpoint object and opening

Are your variables declared within the subroutine that uses them? If not,
they should be. How does the macro fail in this scenario?
/sig

"simonc" wrote in message
...
Your intuition is wonderful. I moved the line oPPTApp.Visible = msoTrue
to
before the Open statement and it worked!

One thing puzzles me. If I run my macro with no Powerpoint instance open
and
the macro creates one and opens the file, and then I close Powerpoint
manually and run the macro again it fails. Something must get set
internally
when it has to create a new Powerpoint application which remains set even
if
you close Powerpoint manually.

"Jon Peltier" wrote:

Check out "Example 3: Using Active PowerPoint Objects if They Exist" on
this
page:

http://peltiertech.com/Excel/XL_PPT.html

I suspect the problem is that Ppt must be visible before opening a
presentation.; I know there's something you have to do in order to do
anything in an invisible instance of PowerPoint, though I haven't used it
in
a couple of years.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______



"simonc" wrote in message
...
There are several threads about opening a powerpoint presentation from
an
Excel macro, and my syntax seems to follow these. However the code
below
(which is just the start of the macro) works if the presentation is
already
open in powerpoint but fails with the message

Presentations (unknown member) : Invalid request. The PowerPoint Frame
window does not exist.

at the line marked with '***** if there is no powerpoint application
open.

Very grateful if anyone can point out where I'm going wrong. I'm using
Office 2000 and Windows XP Pro SP2.

CODE:

Dim oPPTApp As PowerPoint.Application
Dim oPPTShape As PowerPoint.Shape
Dim oPPTFile As PowerPoint.Presentation
Dim SlideNum As Integer
Sub Extract_slide_title_list()
Dim ppt_file As Variant
ppt_file = Application.GetOpenFilename("Powerpoint files
(*.ppt),*.ppt",
, "Select Powerpoint file")
If ppt_file = False Then
Debug.Print "No file name entered. Programme exiting..."
response = MsgBox("No file name entered. Programme
exiting...",
vbExclamation, "Warning")
End
End If

'Look for existing instance of Powerpoint
On Error Resume Next
Set oPPTApp = GetObject(, "PowerPoint.Application")
Set oPPTFile = oPPTApp.Presentations(ppt_file)
On Error GoTo 0
'Create new instance if no instance exists
If oPPTApp Is Nothing Then
Set oPPTApp = CreateObject("PowerPoint.Application")
Set oPPTFile = oPPTApp.Presentations.Open(ppt_file) '**********
End If
oPPTApp.Visible = msoTrue