Accessing PowerPoint files from Excel

M

MWE

I have an application that could be run from Powerpoint with som
interaction with Excel worksheets or from Excel with some interactio
with Powerpoint presentations. I have tried both approach and each ha
problems.

If *Powerpoint is the master*, I create an Excel object, open
workbook, do operations, close and save, and then quit the Exce
object. I am using slightly modified code that runs fine in Outlook.
It runs fine in Powerpoint too unless I try to save the workbook durin
the close. If I do that, the appl hangs. Relevant code is reproduce
below:

'
' define Excel types and definitions
'
Dim xLApp As Excel.Application
Dim xLBook As Excel.Workbook
Dim xLSheet As Excel.Worksheet
Dim xLPath As String, xLFileName As String
'
' define location & filename of target spreadsheet
'
xLPath = ActivePresentation.Path
xLFileName = "SSU_Setup.xls"
'
' define application object
'
Set xLApp = CreateObject("Excel.Application")
'
' open target spreadsheet
' define target worksheet
'
xLApp.Workbooks.Open FileName:=xLPath + "\" +
xLFileName
Set xLSheet = xLApp.Workbooks
(xLFileName).Worksheets("SSU_CurrentProject")
'
' do stuff with the spreadsheet
'
stuff
stuff
'
' close spreadsheet, quit xL
'
xLApp.Workbooks(xLFileName).Close
SaveChanges:=False
xLApp.Quit


This works fine. However if I alter the Close statement to save th
spreadsheet, i.e., SaveChanges:=True the application hangs. If I g
to "Task Manager" and end the PPT session, I am then prompted with
"SAVE AS" window for the spreadsheet. If I try to save the spreadshee
over itself, I get the standard message asking me if I really want t
do that. Regardless of how I answer, the SAVE AS window remains activ
until I cancel it. This inability to save the spreadsheet using th
above code is
unique to PowerPoint, i.e., it seems to work OK in Word and Outlook.

I would rather use *Excel as the master*. I roughed out equivalen
code, relevant stuff is reproduced below

'
' define PPT types and definitions
'
Dim pptApp As PowerPoint.Application
Dim pptPresentation As PowerPoint.Presentation
Dim pptSlide As PowerPoint.Slide
Dim pptPath As String, pptFileName As String
'
' define location and filename of target presentation
'
pptPath = ActiveWorkbook.Path
'
' define ppt application object
'
Set pptApp = CreateObject("Powerpoint.Application")
'
' open PPT file
'
pptApp.Presentations.Open Filename:=pptPath + "\" +PPTFileName


I get an error on the Open statement:

RunTime error
Presentations (unknown member) Invalid request. The Powerpoint fram
window does not exist.

The Open statement is identical to an open statement if Powerpoint wer
that master, but in that case the statement would be:

Application.Presentations.Open Filename:= ...

When I look at the values for pptPath and PPTFileName, they ar
correct.

Any help would be appreciated
 
G

Guest

I've read the post a couple of times (its getting late !!!!) and I have a couple of suggestions that you might find useful...

Instead of using 'SaveChanges:=True' , try using Application.Displayalerts=fals

And as far as opening a file from PP or from XL - investigate using the code to follow a hyperlink - its a much simpler way of doing it than envoking the application

These bits may or may not be what you are after - but hope they are of some use...
 

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