View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
simonc simonc is offline
external usenet poster
 
Posts: 52
Default Creating new Powerpoint object and opening

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