Problem with toolbar button that points to a subroutine

K

Keith

I wrote a subroutine in PowerPoint VBA, then added it to
the toolbar by following the steps: tools --> customize --
commands --> macros --> drag the reference to my
subroutine ie: "MyTask" onto the toolbar.

This works great except that the subroutine exists in only
one .ppt file, and is intended to be used only with
that .ppt file. Unfortunately, when the file containing
the "MyTask" subroutine is not open, the "MyTask" button
stays on the toolbar, and will even run (up to a point)
with errors, of course.

Is there a way that I can have the toolbar reference to
the "MyTask" subroutine appear on the toolbar only when
the correct .ppt file is open?

Thanks

Keith
 
B

Bill Dilworth

Insert this line of code at the beginning of the sub

If ActivePresentation.Name <> "MyPres.ppt" Then Exit Sub


--
Bill Dilworth, Microsoft PPT MVP
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of our questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
K

Keith

HI Bill,

Thanks very much. That's a great idea. If I understand
the code correctly, that would mean, the button always
stays, but becomes inactive if the wrong file is present.
I wonder if there is a way to have the button not be
present unless the correct sub is available.

Any thoughts?

Keith
 
B

B

The route of installing and removing toolbars is best done for the PPT app
level instead of the individual presentation file. But, that does not mean
that you can not create and hide a custom toolbar. This way you can reveal
it when you need it and hide it the rest of the time.

For more info read :
http://www.rdpslides.com/pptfaq/FAQ00031.htm

Bill D.
 

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