ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I add command buttom? (https://www.excelbanter.com/excel-discussion-misc-queries/34662-how-do-i-add-command-buttom.html)

rgarber50

How do I add command buttom?
 

I've written a macro that I want to fire using a command button. I wrote
a macro that adds the button - and one that deletes it just fine.
However I am having problems automating the adding and the deleting of
the button on the standard toolbar - I only want it available for a
particular workbook.

I thought I should be using an event procedure. So I've tried
different combinations of:
Open
Before close
Workbook activate
deactivate.

In the event procedures I am either calling a procedure in a standard
module that adds the button, or a procedure that deletes the button on
the standard toolbar.

Sometimes it runs fine - other times it errors out - sometimes I end up
with multiple buttons. I want to be able to be able to activate another
workbook and have the btn deleted = when back add it again. I also want
to be able to close the workbook and have the button deleted.

Thanks for any suggestions.
Richard


--
rgarber50
------------------------------------------------------------------------
rgarber50's Profile: http://www.excelforum.com/member.php...o&userid=11350
View this thread: http://www.excelforum.com/showthread...hreadid=386011


Anne Troy

It belongs in the Workbook_Open event.
You need to delete it on Before_Close.
*******************
~Anne Troy

www.OfficeArticles.com
www.MyExpertsOnline.com


"rgarber50" wrote
in message ...

I've written a macro that I want to fire using a command button. I wrote
a macro that adds the button - and one that deletes it just fine.
However I am having problems automating the adding and the deleting of
the button on the standard toolbar - I only want it available for a
particular workbook.

I thought I should be using an event procedure. So I've tried
different combinations of:
Open
Before close
Workbook activate
deactivate.

In the event procedures I am either calling a procedure in a standard
module that adds the button, or a procedure that deletes the button on
the standard toolbar.

Sometimes it runs fine - other times it errors out - sometimes I end up
with multiple buttons. I want to be able to be able to activate another
workbook and have the btn deleted = when back add it again. I also want
to be able to close the workbook and have the button deleted.

Thanks for any suggestions.
Richard


--
rgarber50
------------------------------------------------------------------------
rgarber50's Profile:

http://www.excelforum.com/member.php...o&userid=11350
View this thread: http://www.excelforum.com/showthread...hreadid=386011





All times are GMT +1. The time now is 02:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com