so I've written some code that imports data from an excel sheet and creates a nice powerpoint out of it. Now, the issue I'm having is that the makro needs to be executed manually after opening the powerpoint file. I've looked around and automatically running a vba script in PowerPoint seems to be a bit tricky. Apparently you can download a plug-in, but that would only affect my powerpoint version and would require anyone wanting to use that file to also download the plugin right? Any help would be apreciated
Asked
Active
Viewed 2,802 times
0
-
There is an answer [here](https://stackoverflow.com/questions/11306007/how-to-auto-execute-a-macro-when-opening-a-powerpoint-presentation) suggesting that you could create a shortcut using the /M switch that would open a presentation and run a macro. You would still need to persuade people to put the shortcut on their desktop and it will have to point to the correct file location. Alternatively, why not have the presentation open with a blank slide with a large button on it to run the macro (using an Action)? – Andy G Mar 15 '19 at 09:51
-
The second option might work, but don't I need a script to create that button in the first place? Edit: If I don't want to go into presentation mode – timp95 Mar 15 '19 at 10:22
-
You don't need a script to create the button, you can simply insert it on the slide, then choose Action to select the macro that you want to run. Yes, they have to switch to presentation mode. You could add some clear instructions "Press F5 and then click the button". I suppose a macro could also be extended so that, once complete, it pops out of presentation mode. – Andy G Mar 15 '19 at 10:37
1 Answers
1
Without using an add-in, and with limited user involvement, the following approach could be taken.
- Add a single blank slide to the presentation. (The others could be hidden temporarily.)
- Use the Insert tab to add a Shape (or picture)
- With the shape still selected, choose Action from the same Insert tab. This will enable selecting a macro to run when the button/shape is clicked.
The shape can only cause the macro to run when the slide show is running.
- Add a text box with a clear instruction to the user to press F5 to run the show and click the button.
Rather than running the main macro directly, a helper macro could be created that will run the main macro but then also exit the currently running slide show. For example,
Sub Test()
Call MainMacro
ActivePresentation.SlideShowWindow.View.Exit
End Sub
Sub MainMacro()
MsgBox "Doing stuff"
End Sub
It is also possible for the helper macro to unhide the existing slides:
ActivePresentation.Slides(2).SlideShowTransition.Hidden = msoFalse
Rather than modifying the existing presentation, these steps could be created as a separate presentation with a single slide. The complication here is that the main presentation would need to be opened from a reliable location.
This helper presentation could additionally be saved as a PowerPoint Macro Enabled Show
(pppsm).

Andy G
- 19,232
- 5
- 47
- 69
-
No versions of PowerPoint have ever recognized Auto_Open macros, other than as part of add-ins. Other than that minor quibble, good answer! Upvoting it. – Steve Rindsberg Mar 16 '19 at 18:06
-