ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running Powerpoint from Excel (https://www.excelbanter.com/excel-programming/305021-running-powerpoint-excel.html)

Naveen Sukhramani

Running Powerpoint from Excel
 
I wrote this code to activate a powerpoint file (as a slideshow) and
quit powerpoint after the show is through and return to excel.

The problem: Within secs of opening the file in powerpoint it quits
(without running running the entire slideshow.


Sub myShow()
Dim zPPT As PowerPoint.Application
Dim zPres As PowerPoint.Presentation

Set zPPT = CreateObject("Powerpoint.Application")

zPPT.Visible = msoTrue

Set zPres = zPPT.Presentations.Open("prezex.ppt")
zPres.SlideShowSettings.Run

zPPT.Quit

End Sub

xxxxxxxxxxxxxxxxxxxx

Could someone help?

Thanks,

Naveen

Jim Rech

Running Powerpoint from Excel
 
Try using module level variables. Put your Dims at the module top outside
of the subs.

--
Jim Rech
Excel MVP
"Naveen Sukhramani" wrote in message
om...
|I wrote this code to activate a powerpoint file (as a slideshow) and
| quit powerpoint after the show is through and return to excel.
|
| The problem: Within secs of opening the file in powerpoint it quits
| (without running running the entire slideshow.
|
|
| Sub myShow()
| Dim zPPT As PowerPoint.Application
| Dim zPres As PowerPoint.Presentation
|
| Set zPPT = CreateObject("Powerpoint.Application")
|
| zPPT.Visible = msoTrue
|
| Set zPres = zPPT.Presentations.Open("prezex.ppt")
| zPres.SlideShowSettings.Run
|
| zPPT.Quit
|
| End Sub
|
| xxxxxxxxxxxxxxxxxxxx
|
| Could someone help?
|
| Thanks,
|
| Naveen



Naveen Sukhramani

Running Powerpoint from Excel
 
Nope.... didn't quite work. If it helps, I'm using Excel 2000, OS = Win2000.





"Jim Rech" wrote in message ...
Try using module level variables. Put your Dims at the module top outside
of the subs.

--
Jim Rech
Excel MVP
"Naveen Sukhramani" wrote in message
om...
|I wrote this code to activate a powerpoint file (as a slideshow) and
| quit powerpoint after the show is through and return to excel.
|
| The problem: Within secs of opening the file in powerpoint it quits
| (without running running the entire slideshow.
|
|
| Sub myShow()
| Dim zPPT As PowerPoint.Application
| Dim zPres As PowerPoint.Presentation
|
| Set zPPT = CreateObject("Powerpoint.Application")
|
| zPPT.Visible = msoTrue
|
| Set zPres = zPPT.Presentations.Open("prezex.ppt")
| zPres.SlideShowSettings.Run
|
| zPPT.Quit
|
| End Sub
|
| xxxxxxxxxxxxxxxxxxxx
|
| Could someone help?
|
| Thanks,
|
| Naveen


Jon Peltier[_8_]

Running Powerpoint from Excel
 
Naveen -

I'm not sure the Excel macro waits for the entire slide show to run
before executing the zPPT.Quit command. You could add a class module in
your Excel project to capture the PowerPoint events. I used the
following code, which fires the SlideShowEnd event procedure. Apparently
you cannot quit the app from within the event procedure, so I use OnTime
to run a separate procedure that quits PowerPoint, after the event
procedure is finished.

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

Class module in Excel VBA, named CPptAppEvt
'----------------
Option Explicit

Public WithEvents pApp As PowerPoint.Application

Private Sub pApp_SlideShowEnd(ByVal Pres As PowerPoint.Presentation)
Application.OnTime Now + TimeValue("0:00:01"), "EndShow"
End Sub
'----------------

Regular module in Excel VBA
'----------------
Option Explicit

Dim zPPT As PowerPoint.Application
Dim zApp As New CPptAppEvt

Sub myShow()
Dim zPres As PowerPoint.Presentation

Set zPPT = CreateObject("Powerpoint.Application")

Set zApp.pApp = zPPT
zPPT.Visible = msoTrue

Set zPres = zPPT.Presentations.Open _
("C:\Documents and Settings\Jon Peltier\My Documents\prezex.ppt")
zPres.SlideShowSettings.Run
End Sub

Sub EndShow()
Dim preso As PowerPoint.Presentation
For Each preso In zPPT.Presentations
preso.Close 'False
Next
zPPT.Quit '' this line gives the error
End Sub
'----------------


Naveen Sukhramani wrote:

Nope.... didn't quite work. If it helps, I'm using Excel 2000, OS = Win2000.





"Jim Rech" wrote in message ...

Try using module level variables. Put your Dims at the module top outside
of the subs.

--
Jim Rech
Excel MVP
"Naveen Sukhramani" wrote in message
.com...
|I wrote this code to activate a powerpoint file (as a slideshow) and
| quit powerpoint after the show is through and return to excel.
|
| The problem: Within secs of opening the file in powerpoint it quits
| (without running running the entire slideshow.
|
|
| Sub myShow()
| Dim zPPT As PowerPoint.Application
| Dim zPres As PowerPoint.Presentation
|
| Set zPPT = CreateObject("Powerpoint.Application")
|
| zPPT.Visible = msoTrue
|
| Set zPres = zPPT.Presentations.Open("prezex.ppt")
| zPres.SlideShowSettings.Run
|
| zPPT.Quit
|
| End Sub
|
| xxxxxxxxxxxxxxxxxxxx
|
| Could someone help?
|
| Thanks,
|
| Naveen




All times are GMT +1. The time now is 12:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com