Close PPT Presentation programatically at end of last slide

E

ejm3

Is there a way using VBA to close a PPT Presentation at the end of the last
slide? This is to cure a bug in the Viewer which always shows a black slide
at the end of a Presentation. The "exit" code would have to be called as a
result of some automated method like "CloseSlide" or "EndOfSlide" but I
haven't seen such a beast.
 
A

AndyM

If your event handler class resides in a power point add-in (ppa) file, you
can use the OnSlideShowNextSlide event. This will execute before the
transition to the next slide. Within this event, just check if the current
slide is equal to the total number of slides. If it is, then quit the
application (or close the presentation).

currentSlide = Wn.View.Slide.SlideIndex
totalSlides = ActivePresentation.Slides.Count
If currentSlide = totalSlides Then
Application.Quit
'ActivePresentation.Close
End If

For help enabling events in powerpoint, please use this link as a reference:
http://www.pptfaq.com/FAQ00004.htm
 
E

ejm3

Thanks this is great however I left out one small detail :)

I need to modify the Presentation on the fly and then save it. That is, in
my VB application I'm goting to open up the Presentation, edit it and add the
"QuitApplicationOnLastSlide" code using the Office automation object, and
then save the newly edited version of the Presentaion to a new location.

Is this possible with what you have suggested or does it all have to be done
interactively in PowerPoint? Would I need to "package" the add-in along with
the Presentation?
 
A

AndyM

If you want PowerPoint to automatically install your add-in, then save it in
the default "Add-ins" folder. If you will be running this on multiple
computers, it will need to be done for each one.

You can also save your add-in in another location, and manually add it
through regedit.
Registering Add-In: http://support.microsoft.com/kb/q222685/

I believe this code should still work with your VB application opening
PowerPoint. You'll just need to make sure that macros are enabled within
PowerPoint. If you need other Events, there is a good list located at
http://officeone.mvps.org/vba/events_version.html
 
E

ejm3

A couple of more questions before I summarize:

How do you make sure that macros are enabled? I see no option for this.

Will the Viewer pick up/use the add-in code we are discussing? (remember we
are trying to cure a "feature" of the Viewer)

Since you seem to know a lot, is there a way around all of this by simply
setting a registry key or using a command line switch for the Viewer that
would stop it from showing the final black slide?
 
S

Steve Rindsberg

Is there a way using VBA to close a PPT Presentation at the end of the last
slide? This is to cure a bug in the Viewer which always shows a black slide
at the end of a Presentation. The "exit" code would have to be called as a
result of some automated method like "CloseSlide" or "EndOfSlide" but I
haven't seen such a beast.

The viewer doesn't support VBA, so nothing you can do in VBA is of any use
within the Viewer.

How are you advancing slides in the presentation? Manually or is it a timed
show?

Will a user be interacting with it or is it hands-off?
 
A

AndyM

It doesn’t look like VBA is supported in a standalone PowerPoint Viewer. Are
you viewing a presentation from the standalone Viewer or from within
PowerPoint?

To enable macros in PowerPoint, go to Tools > Macro > Security. You can
select Low to always enable macros (not recommended) or you can sign your
macro to always run. There is help about how to do this in other forums.

I am not an expert in PowerPoint (I work with VBA in Excel mostly). There
could possibly be a setting to prevent the final black slide from appearing.
I recommend posting within the PowerPoint newsgroup to get an answer on this.
If there is a setting to do this, it would most certainly be the way to go.
Here is the link to the PowerPoint newsgroup:
http://www.microsoft.com/office/com...?dg=microsoft.public.powerpoint&lang=en&cr=US
 
E

ejm3

Steve,

Thanks for the response. Here is the thread I started in the PowerPoint
forum:
http://www.microsoft.com/office/com...20f8&catlist=&dglist=&ptlist=&exp=&sloc=en-us

I got no response so I moved here assuming there was no other answer.

The Shows must be able to run non-interactively and respond to Slide timing
- like kiosk mode. I'm running these Shows as part of a larger sequence of
events that include many different kinds of media. I must know when the Show
ends (external Viewer process ID no longer exists) in order to move onto the
next event thus my quandary. This was easy when the Viewer was Automated and
even worked as an external process with previous versions. Now there seems to
be no way to get the Viewer into a mode where it just ends after the last
slide.
 
S

Steve Rindsberg

It doesn’t look like VBA is supported in a standalone PowerPoint Viewer.
Correct.

I am not an expert in PowerPoint (I work with VBA in Excel mostly). There
could possibly be a setting to prevent the final black slide from appearing.

In PowerPoint, yes. Tools, Options, View tab, uncheck "End with black slide"

In the Viewer, no.
 
S

Steve Rindsberg

Ah, yes. I saw your post and was hoping that somebody would come up with a better
answer that the best I had (along the lines of "No can do").

I'll assume you can't use a full copy of PPT for this and must use the Viewer?

Have you considered converting the PPT to something that might be more controllable?
Flash, movie files, HTML or the like?
 
E

ejm3

Wow - no can do - what a drag!

Converting to Flash or WMV may do the trick. Here's another thought: make a
playlist consisting of the Presentation in question followed by another
single black slide presentation; then have a thread that simply checks if the
single black slide presentation file is open - as soon as it is kill the
Viewer process and move to the next event.
 
S

Steve Rindsberg

Wow - no can do - what a drag!

Converting to Flash or WMV may do the trick. Here's another thought: make a
playlist consisting of the Presentation in question followed by another
single black slide presentation; then have a thread that simply checks if the
single black slide presentation file is open - as soon as it is kill the
Viewer process and move to the next event.

That's *very* devious. I like it. ;-)
 
E

ejm3

Cheeky - yes indeed.

Any suggestions with respect to format conversion?

Also, I noticed one can save Presentations as "macro-enabled". Would this
enable macros in the Viewer?
 
S

Steve Rindsberg

Cheeky - yes indeed.

Any suggestions with respect to format conversion?

Also, I noticed one can save Presentations as "macro-enabled". Would this
enable macros in the Viewer?

No .. it's not a case of macros being enabled or not in the Viewer, it's that the
viewer offers no support for macros at all.
 

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