Command Buttons to change Slide in Powerpoint?

I have a command button called commandbutton1 from the control toolbox. It is in slide 6, when i click it, i would like it to go to slide 8. Any idea how to do this? I think I need to use VBA, if so, any idea of the script that would be needed?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can do this much easier by going to the slide show menu and inserting an action button from the menu there. When you put one in and draw the size it will automatically pop a dialog box that will allow you to define the hyperlink.

Options for previous, next, last etc are listed first but further in the list you will see an option for Slide...

When you choose that you can give it any slide in your presentation as the button click destination.
good advice, i've been looking for this for 30 minutes and could not get it to work so i'm listening to learn :)
I have known from past experience to leave that control toolbox alone whenever possible.... :-)
Takes forever to even find the right spot to enter any code.
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

somehow activepresentation.slides(index).select is not available at runtime so if you really want to do it the hard way you probably have to catch an event, but i'm curious

maybe someone like TajSimmons jumps in later on, hyperlinking and a shape is much easier to find out, besides that it works ;)
ding-dongAuthor Commented:
I did think about an action button but I did not use it for two reasons:

1. I have two buttons on the slide, one of which uses VBA to do stuff in the slide that is necessary. These buttons are position right next to each other so two different buttons doesn’t look nice.

2. Because it has to be well presented and look professional and I just don’t like the look of action buttons how ever much I try to make them look nice. I know I’m being fussy, sorry.

Ok... then add your command button and then Right click and choose View code.

Enter the following information using your control name (CommandButton1,CommandButton2, etc).

Private Sub CommandButton1_Click()
Application.SlideShowWindows(1).View.GotoSlide (8)
End Sub

This should work when in the Slide Show view (presentation mode)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
:-) wonderfull

knew i had seen that method once in my life should start to store my PAQs in a better manner then using google
ding-dongAuthor Commented:
That’s great! It works thank you. I now have another problem... sorry (I'll increase the value of the question). I have a slide that should last 5 seconds, and then move onto the next slide. I have set it using the slide transition to “automatically after 05:00” but it doesn’t move on after the 5 seconds?

05:00 is 5 hours...00:05 is five seconds
Also if you go to the Slide Show menu and Set-up show make sure that under Advance slides, "using timings if present" is selected.
ding-dongAuthor Commented:
Ok that was just a stupid mistake! Also, is there a way to do something as the slide loads? Like onLoad? In VBA.
Afraid I cant help there. Not aware of the syntax for something like that. What are you trying to get done on Load?
for a slide onload event you need to use an eventhandler addin that you can download, then implement the events you need according to the sample that it includes you probably need the Auto_NextSlide event

Sub Auto_NextSlide(Index as Long) - Gets executed before the slideshow moves onto the next slide. Index represents the SlideIndex of the Slide about to be displayed

ding-dongAuthor Commented:
When one slide loads, I have a few text boxes that the user enters data into, I would like to make sure that everytime that slide is loaded, the text boxes are empty. The code is very basic to do this, its just doing it before the slide loads (Slide6.TextBox1.Text = ""). If I were to use AutoEvents, would it need to be installed on every system that the slide shows runs on?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.