Discussion:
removing commandbarbutton created by addin
(too old to reply)
MikeWorkflow
2005-06-07 19:27:01 UTC
Permalink
I'm having difficulty removing a commandbarbutton from the standard toolbar,
that was created by my addin.

In my research, before adding a button, it appears you should set the
Application.CustomizationContext property. What helped a little was setting
this property to Application.ActiveDocument.

Upon doing this, the button would create upon load and delete when the
application closed, ONLY IF YOU LAUNCHED OFFICE WITHOUT OPENING A DOCUMENT
(such as just clicking the Microsoft Word 2003 shortcut). However, if you
open up a document (for instance, double clicking on a Word doc), my button
no longer deletes when Word closes.

What I'm guessing is the Application.ActiveDocument object value that I am
setting when creating the button upon startup no longer exists once the
application goes to shut down and remove the button, thus orphaning the
button.

It's imperative that this button goes away after use so that when the add in
is uninstalled, I don't have a broken useless button sitting on my toolbar.

Any ideas?

Thanks.
Word Heretic
2005-06-09 07:16:41 UTC
Permalink
G'day MikeWorkflow <***@discussions.microsoft.com>,

Intercept the document close event and remove the button there. That
way app.quit never sees it.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice
Post by MikeWorkflow
I'm having difficulty removing a commandbarbutton from the standard toolbar,
that was created by my addin.
In my research, before adding a button, it appears you should set the
Application.CustomizationContext property. What helped a little was setting
this property to Application.ActiveDocument.
Upon doing this, the button would create upon load and delete when the
application closed, ONLY IF YOU LAUNCHED OFFICE WITHOUT OPENING A DOCUMENT
(such as just clicking the Microsoft Word 2003 shortcut). However, if you
open up a document (for instance, double clicking on a Word doc), my button
no longer deletes when Word closes.
What I'm guessing is the Application.ActiveDocument object value that I am
setting when creating the button upon startup no longer exists once the
application goes to shut down and remove the button, thus orphaning the
button.
It's imperative that this button goes away after use so that when the add in
is uninstalled, I don't have a broken useless button sitting on my toolbar.
Any ideas?
Thanks.
Loading...