How can I get my code to run automatically when a presentation opens?
Problem
You have some neat macros that you want to run automatically whenever you or anyone else opens your presentation or when PowerPoint starts up. How do you make that happen?
You can't. PowerPoint has no way to run code automatically when the user opens a document file.
If you want code to run when PowerPoint opens, you can create an add-in and install it. If the add-in includes a Sub Auto_Open() routine, the code in that routine will run when the add-in loads.
Create an ADD-IN with TOOLBARS that run macros
Your add-in can also respond to events (like Presentation Open) so you can have it run code when a presentation's opened or closed or printed etc.
If an add-in is out of the question or just too much trouble ...
If an add-in isn't in the cards, there's another dodge that may help if you're trying to get code in a Slide Show (PPS or PPSX) to run:
- Start your presentation with a simple intro-type slide that includes a Click Here button of some sort. Set the button's Action Setting to Run Macro and select the subroutine/macro you want it to run.
- Or add a rectangle that completely covers the slide, make it invisible, and assign it a MouseOver action setting to run the macro. As soon as the show starts and the mouse moves, it'll trigger your macro.
- The macro should end with a line like this, to automatically advance the presentation to the next slide:
ActivePresentation.SlideShowWindow.View.GotoSlide (2)
Set the presentation to Kiosk mode and include any other navigation buttons a user will need to view the presentation.