Automating a macro

G

Goody

I have written a PowerPoint macro that I would like to run when a new
presentation is started using the template containing the macro. I have
declared an object variable in a class module, but apparently I need to
automate the initialization of the declared object from another module.

I have tried listing the code in the App_NewPresentation subroutine, but
that doesn't work. My macro, shown below, installs a control in the Frames
context menu. Selecting the control should run the SecondSlide macro, which
is located in a module. The macro itself works as intended, when run from a
module, but I need to automate it so that the context menu is modified as
soon as a new presentation is created. Can this be done?

Set myControl = CommandBars("Frames").Controls _
.Add(Type:=msoControlButton, Before:=1) ' Add new control at start of
Frames menu.
With myControl
.Caption = "Select Second Slide" ' Define caption.
.OnAction = "SecondSlide" ' Identify macro to run.
End With

What am I overlooking?
 
B

Bill Dilworth

While you can create and save macros in POT files, they are not imported
into the presentation that uses them (unlike Word and Excel). You should
create an add-in with the macros that adds a new control.

Create an ADD-IN with TOOLBARS that run macros
http://www.pptfaq.com/FAQ00031.htm


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top