Persistent ControlBarButton with Word 2003 Add-in

K

KenWilson

I have a shared add-in for Word 2003 written in C# using Visual Studio 2005.
When this add-in is uninstalled the button it places on the Tools dropdown
menu continues to persist until it is deleted manually. The button is added
in the OnStartupComplete method and 'true' is being passed as the Temporary
argument. I have attempted to call the button's Delete method in
OnShutDownBegin but to no avail.

One item I have seen that may speak to this issue is that normal.dot is
possibly being saved while the button is still in place and before
OnBeginShutdown is called. Is there someway I can intercept the saving of
normal.dot before it occurs and delete the button?

Thanks in advance for your assistance.
 
S

Sigurd Stenersen

KenWilson said:
I have a shared add-in for Word 2003 written in C# using Visual
Studio 2005. When this add-in is uninstalled the button it places on
the Tools dropdown menu continues to persist until it is deleted
manually. The button is added in the OnStartupComplete method and
'true' is being passed as the Temporary argument. I have attempted
to call the button's Delete method in OnShutDownBegin but to no avail.

One item I have seen that may speak to this issue is that normal.dot
is possibly being saved while the button is still in place and before
OnBeginShutdown is called. Is there someway I can intercept the
saving of normal.dot before it occurs and delete the button?

Thanks in advance for your assistance.

I think the simplest solution is to just save normal.dot after you delete
the button.


Sigurd
 
K

KenWilson

Sigurd Stenersen said:
I think the simplest solution is to just save normal.dot after you delete
the button.
You have simply paraphrased the solution I wish to arrive at but have
provided nothing in the way of how. Thank you for your effort though.
 
S

Sigurd Stenersen

KenWilson said:
You have simply paraphrased the solution I wish to arrive at but have
provided nothing in the way of how. Thank you for your effort though.

That is not the solution you ASKED for. You asked for a way to intercept
the saving when Word does it, I told you that it is easier to do something
else.


Sigurd
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?S2VuV2lsc29u?=,
I have a shared add-in for Word 2003 written in C# using Visual Studio 2005.
When this add-in is uninstalled the button it places on the Tools dropdown
menu continues to persist until it is deleted manually. The button is added
in the OnStartupComplete method and 'true' is being passed as the Temporary
argument. I have attempted to call the button's Delete method in
OnShutDownBegin but to no avail.
Are you explicitly setting the CustomizationContext both when creating and when
deleting the button? If not, then Word is probably deleting it from the current
document context, rather than NormalTemplate...

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 :)
 
K

Ken Wilson

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

Are you explicitly setting the CustomizationContext both when creating and when
deleting the button? If not, then Word is probably deleting it from the current
document context, rather than NormalTemplate...

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 :)

I gave this a try. Unfortunately, if I set the CustomizationContext
to Application.ActiveDocument when the add-in loads the
CommandBarButton is not available for any other documents you might be
creating during that session. (This add-in loads on Word startup)

Ken Wilson
Seeking viable IT employment in Victoria, BC
 
C

Cindy M -WordMVP-

Hi Ken,
I gave this a try. Unfortunately, if I set the CustomizationContext
to Application.ActiveDocument when the add-in loads the
CommandBarButton is not available for any other documents you might be
creating during that session. (This add-in loads on Word startup)
:) At least we know CustomizationContext works.

You misunderstood me: do you explicitly set CustomizationContext =
NormalTemplate when you send the DELETE command? That should remove the
button explicitly, rather than leave it "hanging"...

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 :)
 
K

Ken Wilson

Hi Ken,

:) At least we know CustomizationContext works.

You misunderstood me: do you explicitly set CustomizationContext =
NormalTemplate when you send the DELETE command? That should remove the
button explicitly, rather than leave it "hanging"...

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 :)

I have attempted setting the CustomizationContext in the three
possible combinations and none has worked. I am inclined to believe
that this is not possible without creating a special template which is
not on the radar for this solution. I am coming to this understanding
because of items discussed in the article on this web page.

http://www.codeproject.com/csharp/wordaddinpart1.asp

Ken Wilson
Seeking viable IT employment in Victoria, BC
 
C

Cindy M -WordMVP-

Hi Ken,
I have attempted setting the CustomizationContext in the three
possible combinations and none has worked. I am inclined to believe
that this is not possible without creating a special template which is
not on the radar for this solution. I am coming to this understanding
because of items discussed in the article on this web page.

http://www.codeproject.com/csharp/wordaddinpart1.asp
Hmmm. David doesn't mention anywhere that CustomizationContext doesn't
work. Only that you can't rely on Temporary:=true.

You're the first preson to come along, in my experience, who has
difficulties with the CustomizationContext not working. Interesting. You
do send NormalTemplate.Save right after you delete the commandbar
control in that CustomizationContext, right?

If you set up your own menu (instead of placing the control in Word's
Tools menu), do you get more predictable/constant results?

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 :)
 
K

Ken Wilson

Hi Ken,

Hmmm. David doesn't mention anywhere that CustomizationContext doesn't
work. Only that you can't rely on Temporary:=true.

You're the first preson to come along, in my experience, who has
difficulties with the CustomizationContext not working. Interesting. You
do send NormalTemplate.Save right after you delete the commandbar
control in that CustomizationContext, right?

I am following some Microsoft sample code verbatim except for the
method which handles our button click. At no point was there any
mention of CustomizationContext. I am attempting to delete the button
in the OnBeginShutdown method required when inheriting from
IDTExtensibility2.
If you set up your own menu (instead of placing the control in Word's
Tools menu), do you get more predictable/constant results?

I took a run at some other sample code that Microsoft provides that
adds a new menu item and two controls. It is subject to the same
problem. When the add-in is uninstalled the menu and its controls
remain. Again, no mention in their code of CustomizationContext.
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 :)

Ken Wilson
Seeking viable IT employment in Victoria, BC
 
K

Ken Wilson

Hi Ken,

Hmmm. David doesn't mention anywhere that CustomizationContext doesn't
work. Only that you can't rely on Temporary:=true.

David does state that the button is probably permanent. "The downside
is you’re adding your menus to the default template (normal if you
don’t change it) permanently. I don’t think you can have menus exist
for the life of the application, but not have them added to the
template."

That is our dilemma. We need this add-in available right from the
onset because it allows Word to communicate with a remote server. We
may just put this in the readme.txt file as a known issue and tell
users the work around is to manually delete the button if the add-in
has been uninstalled from the machine.

Ken Wilson
Seeking viable IT employment in Victoria, BC
 
S

Sigurd Stenersen

Ken said:
David does state that the button is probably permanent. "The downside
is you're adding your menus to the default template (normal if you
don't change it) permanently. I don't think you can have menus exist
for the life of the application, but not have them added to the
template."

That is our dilemma. We need this add-in available right from the
onset because it allows Word to communicate with a remote server. We
may just put this in the readme.txt file as a known issue and tell
users the work around is to manually delete the button if the add-in
has been uninstalled from the machine.

Like I told you before - and this is something you probably would have
noticed if you had a differendt attitude - all you need to do is save
normal.dot right after you call Delete() on the button.


Sigurd
 
K

Ken Wilson

Like I told you before - and this is something you probably would have
noticed if you had a differendt attitude - all you need to do is save
normal.dot right after you call Delete() on the button.
One: I tried your suggestion and it doesn't work.

Two: You haven't seen attitude, however, it can be arranged if such is
your desire. At least Cindy has spent the time to work through a
couple of scenarios and allow me to test before responding to her. As
I stated before you simply restated one possible solution that I had
already considered and queried, possibly in different terms, and
offered no assistance on the mechanics of how you get that set up to
work. It is one thing to say what a person should do, another thing
to show them.

Sincerely,

Ken Wilson
Seeking viable IT employment in Victoria, BC
 
S

Sigurd Stenersen

Ken said:
One: I tried your suggestion and it doesn't work.

I am using this logic myself, and it certainly *does* work.

In the OnDisconnection() handler, you call Delete() on whatever you want to
remove, and then you do an App->NormalTemplate->Save()

I'm using C++ but I don't see how this would be different in any other
programming language.

Two: You haven't seen attitude, however, it can be arranged if such is
your desire. At least Cindy has spent the time to work through a
couple of scenarios and allow me to test before responding to her. As
I stated before you simply restated one possible solution that I had
already considered and queried, possibly in different terms, and
offered no assistance on the mechanics of how you get that set up to
work. It is one thing to say what a person should do, another thing
to show them.

Yes, you do have an attitude problem. I gave you the solution right away,
and you came back with a smart-ass response.

As for spending time on you, I'm regretting answering your request in the
first place. If you had reacted differently, I would have handed you the
details right away. And I don't have any idea why I'm doing it now.


Sigurd
 
K

Ken Wilson

I am using this logic myself, and it certainly *does* work.

In the OnDisconnection() handler, you call Delete() on whatever you want to
remove, and then you do an App->NormalTemplate->Save()

I'm using C++ but I don't see how this would be different in any other
programming language.



Yes, you do have an attitude problem. I gave you the solution right away,
and you came back with a smart-ass response.

As for spending time on you, I'm regretting answering your request in the
first place. If you had reacted differently, I would have handed you the
details right away. And I don't have any idea why I'm doing it now.
To quote your initial reply to my first query in this newsgroup:

"I think the simplest solution is to just save normal.dot after you
delete the button."

That much I had already discerned. And I'm not using C++, I'm using
C# so I have a number of constraints that you do not have to deal
with. For example, I cannot talk to a COM object directly whereas you
can. I have to go through a primary interop assembly.

Let's just say we differ on our idea of what help or assistance is and
agree not to get involved in each others postings.

Ken Wilson
Seeking viable IT employment in Victoria, BC
 
S

Sigurd Stenersen

Ken said:
To quote your initial reply to my first query in this newsgroup:

"I think the simplest solution is to just save normal.dot after you
delete the button."

That much I had already discerned. And I'm not using C++, I'm using
C# so I have a number of constraints that you do not have to deal
with. For example, I cannot talk to a COM object directly whereas you
can. I have to go through a primary interop assembly.

Let's just say we differ on our idea of what help or assistance is and
agree not to get involved in each others postings.

Idiot


Sigurd
 

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