run vba procedure on slide 5

C

Candace

I have created a vba procedure. I know how to tie a procedure to an action
button, but I need this procedure to run when slide 5 becomes active/visible,
during the course of the slideshow. How can I accomplish this?
 
D

David M. Marcovitz

The easiest way to do this is to have the procedure that takes you to
slide 5 also run the macro. If you aren't using a procedure to do this,
then you set up a procedure to do this:

Sub GotoSlide5()
ActivePresentation.SlideShowWindow.View.GotoSlide 5
CoolSlide5Stuff
End Sub

Sub CoolSlide5Stuff()
'Put all the stuff you want to do on slide 5 here
End Sub

If you can't have a button take you to slide 5, then you have to use
event trapping.

--David
 
J

John Wilson

Try something based on this code (replace the message box with your code or a
call to the sub routine)

Sub OnSlideShowPageChange()
If ActivePresentation.SlideShowWindow.View.CurrentShowPosition = 5 Then
MsgBox "this is slide 5 put your code here"
End If
End Sub
--
-------------------------------------------
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
 
D

David M. Marcovitz

Thanks, John. So why didn't I know about that? In what version did this
start working? I thought you had to do some fancy event trapping to know
when the slide changed.
--David
 
J

John Wilson

It's a "pseudo event" left over from 97 that still works (Shyam explained
this at the Summit! There doesn't seem to be much if any documentation.)
There are others:

OnSlideShowTerminate
OnSlideShowNextBuild
OnSlideShowPreviousBuild

John
--
-------------------------------------------
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
 

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