Deleting a toolbar button

H

Harry-Wishes

I created a toolbar with a couple of buttons associated with a template. What
I would like to do is programmatically have the button do what I instructed
when it is clicked but also have the button self-destruct for lack of a
better term. Essentially, the clicking would have a dual purpose in this
order.

1) Run the script I attached to the button.
2) Delete this very button that launched the script.

In case you're wondering why I would want to do this, I only want the user
to run the script once. Double excecution would be disastrous for the program
I'm designing - trust me. At least this will make it harder to re-run the
script since techically-speaking the script is still available, just not as a
button.

Can this be done? Here is what I have so far.

Dim ctlToggle As Office.CommandBarButton
Set ctlToggle = CommandBars("Letter_Toolbar").Controls(1)
 
D

Doug Robbins - Word MVP

A different approach would be to have your code check for the value of a
variable in the document and only run the code if it does not exist. You
will get a 5825 error if the variable does not exist.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.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