Using and Add-in to perform Auto_Open

G

Guest

How can I get an Add-in to execute code in the Auto_Open macro only for
specific PPT files that I load? I've read through the examples and
downloaded the code samples, but everything I see only calls subroutines and
functions that are also in the add-in file. I.e., it executes every time
PowerPoint starts.

I'm written some code that will automatically update the footer of my slides
with the filename; so that it will always show the correct filename even when
someone does a SaveAs to a new name. But I don't want this same thing to
happen to any other PowerPoint slides I load/save.

Ideally, I'd like to do what Shyam Pillai did in his "autoevents" addin, but
he didn't provide the source code that I could find. I like the idea of
putting a "Auto_ShowBegin" routine in my slide presentation so that the
add-in calls it if the routine exists. But, when I try to do that in my
add-in, it won't compile because it can't resolve the name of the routine I
want to call in my PPT file. How does Shyam make an add-in that calls a
routine named "Auto_ShowBegin" when that routine exists in a different file
than the add-in?

Thanks for your help!
 
S

Steve Rindsberg

What Bill said.

And as a working strategy, look at responding to the PresentationOpen and
possibly NewPresentation events. Have the event handling routine check for some
unique property of your presentation (say, the presence of a specially named or
tagged shape that represents your footer) and do nothing unless that shape's
found.
 
G

Guest

I read through the FAQ again, but, unless I'm misunderstanding something, it
still doesn't tell me how to do what I'm trying to do. There are several
references online on this topic, but they all depend on all the code
executing within the addin. I want to call code that's in in my PPT file
like Shyam Pillai does in his AutoEvents demo. Using his AutoEvents addin,
he allows me to put an event, e.g., Auto_ShowBegin, in my PPT file; not in my
PPA file, and it gets called when events occur in my PPT file. How does
Shyam compile a PPA file that makes calls to a PPT file when the PPT file
doesn't exist at the time he compiles the PPA? If I was writing this
functionality in C, I would just create a stub file so the linker could
resolve the addresses, but I can't do that in PowerPoint.

Any help would be greatly appreciated.
 
S

Steve Rindsberg

When you wrote: "How can I get an Add-in to execute code in the Auto_Open macro only
for specific PPT files that I load?" I think I misinterpreted what you're after.

This in your addin would fire off Sub Auto_ShowBegin in your presentation:

Application.Run "FileName.PPT!Auto_ShowBegin"

Or more likely, something like:

Application.Run ActivePresentation.Name & "!Auto_ShowBegin"

You'd want that to be thoroughly error trapped, of course.
 
G

Guest

Yes! Thank you!

The Run method is exactly what I'm looking for. That's pretty cool; it's
like late binding. I can think of a lot of things I can do with that method.
:)

Rather than using "ActivePresentation" I'll probably trap the Pres object
from one of the standard events and use that.

Thanks!
 
S

Steve Rindsberg

Yes! Thank you!

The Run method is exactly what I'm looking for. That's pretty cool; it's
like late binding. I can think of a lot of things I can do with that method.
:)

Rather than using "ActivePresentation" I'll probably trap the Pres object
from one of the standard events and use that.

That might be a better idea. Or in the case of events that pass shapes, the shape's
Parent.Parent property would give you a ref to the presentation.
 
G

Guest

I still don't get this. Where in the Add-In do I put the code:

Application.Run ActivePresentation.Name & "!Auto_ShowBegin"

If I put it in the Auto_Open sub in the Add-In it doesn't run correctly as
there is not yet an active presentation.
 
S

Steve Rindsberg

I still don't get this. Where in the Add-In do I put the code:

Application.Run ActivePresentation.Name & "!Auto_ShowBegin"

If I put it in the Auto_Open sub in the Add-In it doesn't run correctly as
there is not yet an active presentation.

Right. You'd want the Auto_Open sub to set up event handling.
You'd have the event handling routine respond to the SlideShowBegin event and run
whatever code you need then.
 

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