Using VBA to navigate slides in a presentation?

F

flying_pig

As a newbie I assume this is a trivial question but I can't get the syntax
right.

I have a number of slides with several drawing objects on each.

I have a simple menu as part of the presentation screen (as a master slide)
to launch macros that among other things, each needs to show a specific slide
(I have named each slide) and the objects on them are selectively made
visible/not visible.

All I am seeking is a line or two of VBA that will enable random access to
slides in my slide show.

I show/hide shapes using syntax like this:

ActivePresentation.Slides(1).Shapes("MyShape").Visible = msoTrue
ActivePresentation.Slides(1).Shapes("MyShape").Visible = msoFalse

but have not suceeded in selecting the required slide ( and showing it) yet.

Any tips would be appreciated

Thanks

Bob L
 
D

David M. Marcovitz

When you say "random," do you really mean random, or do you mean that you
want to be able to click on a button to take you to a specific slide? If
you just want to go to a specific slide, then you can do something like:

ActivePresentation.SlideShowWindow.View.GotoSlide 5

That takes you to slide 5 (change the 5 to whatever you want). If you
truly mean random (or pseudo-random since I said "truly" and there might
be some mathematicians listening), then you are talking about something a
bit more complicated. You might look at Exampels 8.16 and 8.17 on my site
(http://www.PowerfulPowerPoint.com/) to get one idea of how to move to a
random slide.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
F

flying_pig

David,

I meant radom in the RAM sense i.e. user has free choice rather than
sequential.

I will try your code but I think I had problems with that. I also wish to
refer to the slides by the name I have given them.

Thanks
 
F

flying_pig

David,

I have now checked slide access using the suggested code and that works fine
using the numerical position of the slide as the value in the code e.g. 5 for
the fifth slide. However I wanted to goto my named slide e.g. "MyNamedslide"

Thank you
 
D

David M. Marcovitz

Steve's code is the complete version with all the bells and whistles
(mainly error checking). I usually use something like:

ActivePresentation.SlideShowWindow.View.GotoSlide _
ActivePresentation.Slides("MyNamedSlide").SlideIndex

It's simple, but if you screw up (like trying to go to a named slide that
doesn't exist), it won't do anything.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
F

flying_pig

David,

This is even better for my purpose as I keep a list of all slide and object
names and have a macro to read/write/edit them if needed.
 

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