Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Creating new Powerpoint object and opening

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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Creating new Powerpoint object and opening

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





  #4   Report Post  
Posted to microsoft.public.excel.programming
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







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste object from excel to powerpoint Aaron Excel Programming 5 February 6th 08 04:13 PM
Chart to PPT without opening PowerPoint Abdul[_2_] Excel Programming 2 November 9th 06 01:06 AM
VB script in Excel object in Powerpoint (Urgent) epak Excel Discussion (Misc queries) 1 March 24th 06 05:04 PM
Creating a Powerpoint object (in XP onwards) with an ActiveWindow BizMark Excel Discussion (Misc queries) 0 August 12th 05 12:46 PM
Importing Excel Object in Powerpoint technically challanged Excel Discussion (Misc queries) 0 January 31st 05 09:25 PM


All times are GMT +1. The time now is 01:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"