• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 887
  • Last Modified:

PowerPoint 2007 - automatically run macro when create new presentation

Hi Experts
I need to be able to run a (VBA) macro automatically whenever a new presentation is created based on a particular template - similar to the AutoNew macro in Word.  Please can you tell me how to go about this?  Somehow I suspect it is not going to be as easy as it sounds.
Many thanks.
1 Solution
Chris BottomleyCommented:
Hello MonteDelMar,

Take a look at the following page:



You are correct it won't be easy.

As Chris's link says Auto_Open will only work in an addin not a template AND it will fire when the addin loads NOT when a new presentation loads.

You will have to trap the newpresentation event and run a macro that checks the template name and acts accordingly. Not simple and again will need to be in an addin.

There's a tutorial here which deals with events
(you may have to register)

MonteDelMarAuthor Commented:
Thank you both for your responses.

Both articles relate to pre - 2007 versions of PowerPoint.  I followed the steps on the vbaexpress.com site as I want the code to run when a new presentation is created.  It did not seem to work.  I changed the code to display a message box saying 'Hello" but that did not work either.

Here is exactly what I did:

1. Created the code as described on the vbaexpress site.
2. Saved the template as a PPT add-in (.ppam).
3. Went to PowerPoint options, Add-Ins, Manage + PowerPoint Addins and added the .ppam file.
4. Closed and re-started PowerPoint.
5. Decided to amend the code to display a message (as described above).
6. Tried to open the .ppam version of the file but could not do so.  Should I be able to?
7. Unfortunately had not saved it in any other form so created a new presentation, added the code but with a message box instead of code to close the initial file, saved it as .potm and then as .ppam file.
8.  Loaded the addin as before.
9. Close & re-started PowerPoint.
10.  Expected to see the message but nada - nothing happens at all.
I attach a Word file with the code as I cannot attach the .potm or .ppam file types.
Please can you tell me what I am doing wrong?
Thank you.
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Code looks fine.

Did you rename the class module? It would have to be cEventClass (to work with this 'As New cEventClass')
I uploaded a pptm file (zipped) to
MonteDelMarAuthor Commented:
Yes, I did rename the class module.
I downloaded the file you gave me a link to but there does not appear to be any code in it.

That should be fixed now!
MonteDelMarAuthor Commented:
Sorry, still no macros in this file.  I have macro security set to the lowest level.
There definitely are (i just downloaded it) maybe you have a cached site?
MonteDelMarAuthor Commented:
Thank you - got it this time.  Just to check - I would expect this to display a message box saying 'Hello'  when I create a new presentation.  Do you agree?  Nothing happens though.
I believe the add-in is correctly loaded & attach snapshots to show that.  Also, the version I am using is SP2.  I did close & re-start PowerPoint after loading the addin.
Take out the line which releases the object in the class module this prevents it firing after the first time. It then works for me.

    Set cPPTObject.PPTEvent = Nothing
MonteDelMarAuthor Commented:
That suggestion makes perfect sense but sorry, still nothing.  I must be doing something silly.  I have re-saved the .ppam version with a different name.  Having removed the other one, this new one is now definitely listed in the Add-Ins.

When PowerPoint starts there is a blank presentation but no message.  I close that presentation and create a new blank presentation - still nothing.
Can you mail me the ppam?
john AT SIGN pptalchemy.co.uk
There's also a nice tutorial from MS:
To add

The user did send me the ppam file and it worked fine here and was coded correctly.

Doesn't work for her though even though it shows as loaded and security is set to Low.
MonteDelMarAuthor Commented:
I will try to achieve this in 2003.  If I can get it working there then I will try using the same file in 2007.  I will update this post in the coming week.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now