People often ask "How do I make this macro run every time I show a new slide or add a new slide etc." This means making PowerPoint respond to that EVENT and, unlike in Excel, it's not that easy!
First, I would avoid using the pseudo events left over from version 97, e.g., Sub OnSlideShowpageChange. Pseudo events are not properly supported in later versions of PowerPoint and so will work erratically.
Also, naming your sub Auto_Open will not work in a standard presentation but will in a PPA (version 97-2003) or a PPAM (version 2007/2010) AddIn.
So, let's create a simple AddIn...
1. Add a Class
A. In the VB editor INSERT >> CLASS MODULE
B. If the properties window isn't already visible, press F4 or View > Properties window to show it. Use this to rename the class module to something more memorable. We used cNewSlideClass.
A. Back in the class module you will see two drop down menus at the top of the page.
Change the left one to PPTEVENT; the right, select the event to fire your macro. In our case PresentationNewSlide.
B. Between the lines of code auto inserted add the code you want to run.
Here is ours:
Private Sub PPTEvent_PresentationNewSlide(ByVal Sld As Slide) MsgBox "You inserted slide " & Sld.SlideIndexEnd Sub
This is a great article JSRWilson. I'd just like to add that if a developer is looking for a cross-platform compatible solution for application events that will work on PC and Mac versions of PowerPoint, there doesn't appear to be one. Why?
Application Events are supported by PC versions of PowerPoint only (as of PowerPoint:mac 2011, and possible PowerPoint:mac 2016)
Psuedo Events are supported by PC and Mac versions but they are unreliable and in many cases will cause PowerPoint to crash
Finally, to get around the Auto_Open limitation of only firing within an add-in (as opposed to a presentation), you can use this article to solve that issue (again, only for PC versions of PowerPoint supporting the ribbon):
Comments (1)
Commented:
Finally, to get around the Auto_Open limitation of only firing within an add-in (as opposed to a presentation), you can use this article to solve that issue (again, only for PC versions of PowerPoint supporting the ribbon):
http://www.experts-exchang