VBA code in PPT2007

R

RJ

Can anyone help with the following:
I want a vba code which will take me to the second previously viewed slide
minus 1.

Example:
Slide #3 is viewed. An action button then takes the viewer to slide#7.
Another action button takes the viewer to slide #10. On slide #10 I would
like there to be an action button connected to a macro that will take the
viewer directly to slide #2. (To the previous slide viewed (#7), then the
next previous slide viewed (#3), then to the slide positioned just before
slide #3 (#2).

Can this be done?

Thanks.
RJ
 
D

David Marcovitz

Can anyone help with the following:
I want a vba code which will take me to the second previously viewed slide
minus 1.

Example:
Slide #3 is viewed. An action button then takes the viewer to slide#7.
Another action button takes the viewer to slide #10. On slide #10 I would
like there to be an action button connected to a macro that will take the
viewer directly to slide #2. (To the previous slide viewed (#7), then the
next previous slide viewed (#3), then to the slide positioned just before
slide #3 (#2).

Can this be done?

Thanks.
RJ

This is definitely doable, but it is going to require some coding. This
is untested off the top of my head, but it should get you started.

Dim prevSlide as Long
Dim prevPrevSlide as Long


'Call this procedure with a number and it will go to that slide
'keeping track of the last two slides visited
Sub GotoNewSlide (theNewSlide as Long)
prevPrevSlide = prevSlide
prevSlide = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
ActivePresentation.SlideShowWindow.View.GotoSlide theNewSlide
End Sub


'Go to the previous previous slide - 1
Sub GoBackBackMinus1()
If prevPrevSlide <= 1 Or prevPrevSlide >
ActivePresentation.Slides.Count Then
'Decide what you want to do if you can't do what you want
'and put it here
Else
GotoNewSlide(prevPrevSlide - 1)
End If
End Sub

Just be sure that every time you want to go to a slide, you call
GotoNewSlide, instead of a regular hyperlink because that is what keeps
track of the previous slides. An alternative is to use an event trap to
trap every time you change slides, but someone else would have to help
you with that.

--David

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
J

John Wilson

There is code here to do this:
http://www.pptalchemy.co.uk/vbasamples.html

RJ said:
Can anyone help with the following:
I want a vba code which will take me to the second previously viewed slide
minus 1.

Example:
Slide #3 is viewed. An action button then takes the viewer to slide#7.
Another action button takes the viewer to slide #10. On slide #10 I would
like there to be an action button connected to a macro that will take the
viewer directly to slide #2. (To the previous slide viewed (#7), then the
next previous slide viewed (#3), then to the slide positioned just before
slide #3 (#2).

Can this be done?

Thanks.
RJ

__________ Information from ESET Smart Security, version of virus
signature database 5089 (20100505) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5089 (20100505) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 

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