Uninstalling word Add-in does not remove any UI changes done by Ad

K

KarthikRamz

Hi,
I have a word add-in written in VS 2005 using the Shared Add-in project.
Through the add-in I am placing a simple button on the standard toolbar. The
button shows up on the standard toolbar appropriately.
Now when I uninstall the add-in, the button does not get removed.

I am creating the button object in the OnStartUpComplete event handler as
follows:

object omissing = System.Reflection.Missing.Value;
MyButton =
(CommandBarButton)oStandardBar.Controls.Add(1, omissing, omissing, omissing,
true);
MyButton.Caption = "My button";
MyButton.Style = MsoButtonStyle.msoButtonCaption;

And I am disposing the button object in the OnBeginShutDown event handler as
follows:
object omissing = System.Reflection.Missing.Value;
MyButton.Delete(omissing);
MyButton = null;
((WORD.Application)applicationObject).NormalTemplate.Save(); //
I came through some posting which suggested adding this line, but it did not
help.

The button does not get deleted. Am I missing some thing here?

Thanks!
Karthik
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?S2FydGhpa1JhbXo=?=,

Word can save toolbars (and changes to them) in many different places: the
global template (NormalTemplate), and other loaded global template (template
Addin), the current document, that document's attached template.

Therefore, it's of the utmost importance that you explicitly specify to which
CustomizationContext your commandbar manipulations apply. The code you show us
does not explicitly set the Application.CustomizationContext before creating
nor before destroying the button. If you don't include that, then chances are
Word is not deleting the button in the context in which it created it.
I have a word add-in written in VS 2005 using the Shared Add-in project.
Through the add-in I am placing a simple button on the standard toolbar. The
button shows up on the standard toolbar appropriately.
Now when I uninstall the add-in, the button does not get removed.

I am creating the button object in the OnStartUpComplete event handler as
follows:

object omissing = System.Reflection.Missing.Value;
MyButton =
(CommandBarButton)oStandardBar.Controls.Add(1, omissing, omissing, omissing,
true);
MyButton.Caption = "My button";
MyButton.Style = MsoButtonStyle.msoButtonCaption;

And I am disposing the button object in the OnBeginShutDown event handler as
follows:
object omissing = System.Reflection.Missing.Value;
MyButton.Delete(omissing);
MyButton = null;
((WORD.Application)applicationObject).NormalTemplate.Save(); //
I came through some posting which suggested adding this line, but it did not
help.

The button does not get deleted. Am I missing some thing here?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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