removing menus when uninstalling an AddIn

D

David Thielen

When a user uninstalls our AddIn on Office 2000/2002/2003 the menu is
still there in Word/Excel/PowerPoint. As I understand it, the only way
for us to uninstall the menus is:

1) Close all copies of Office
2) Remove AutoTag
3) Add a new AddIn that will remove us from the menu
4) Start & exit Word, Excel, & PowerPoint each so the new
5) AddIn will uninstall us from the menu.
6) Remove the new AddIn.

Is there an easier way to have our menus removed from Office? Maybe a
registry setting we can hit?

thanks - dave

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Ji Zhou [MSFT]

Hello Dave,

In order to make the custom command bar and controls do not remain in the
Office application after uninstalling the Add-in, we need to create them as
temporary bars or controls. Temporary bars/controls are automatically
deleted when the container application is closed. This behavior is
controlled by CommandBars.Add()/CommandBarControls.Add() functions'
Temporary parameter.

The corresponding document is available here:
http://msdn.microsoft.com/en-us/library/aa141979(office.10).aspx. See the
explanations for the Temporary parameter.

I also write some test codes on my side. It works fine. I uninstall my
Add-in and restart all Office application. My custom command bar and
controls disappear.

Office.CommandBar cb;
Office.CommandBarComboBox edt;
Office.CommandBarButton btn;
Object missing = Type.Missing;

public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
applicationObject = application as Word.Application;

cb = applicationObject.CommandBars.Add("test",
Office.MsoBarPosition.msoBarTop,
false, true) as Office.CommandBar;
cb.Visible = true;
cb.Protection = Microsoft.Office.Core.MsoBarProtection.msoBarNoCustomize;

edt = cb.Controls.Add(Office.MsoControlType.msoControlEdit, missing,
missing, missing, true) as Office.CommandBarComboBox;
edt.Caption = "My Editor";
edt.Tag = "My Editor";

btn = cb.Controls.Add(Office.MsoControlType.msoControlButton, missing,
missing, missing, true) as Office.CommandBarButton;
btn.Caption = "My Button";
btn.Tag = "My Button";
}

Please let me know whether the suggestion works for you or not. And if you
have any concerns or questions on this, please feel free to contact me.


Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

Tony Jollans

In Word ...

There are sometimes 'funnies' with CommandBars, especially if they are
installed on Open rather than being stored in the AddIn but if they remain
following uninstall they are not in the AddIn in the first place. How are
you creating them - and with what CustomizationContext?
 
M

Maneesh S

I have run into similar problem when creating menu for Office application.
With Excel and Powerpoint it was easy solution uninstalling the menu, just
set the Temporary to true when using commandbars.add (as mentioned by "Ji
Zhou [MSFT]").

It was a bit tough for Word application since setting temporary did not work
well Word. In word, menu would get saved in Normal.dot template. (after the
application was uninstalled the menu would still exist unless Normal.dot is
deleted and recreated). To overcome this I create a custom template (via
Automation, using Add method of Word) and added it as a global template, set
customizationcontext to my global template, create my menus, set template
saved property to true and revert customizationcontext to normaltemplate.

Hope this helps
 
D

David Thielen

Yep, we faced that same problem when we made them temp. I'll take a
look at the custome template work-around.

thanks - dave



I have run into similar problem when creating menu for Office application.
With Excel and Powerpoint it was easy solution uninstalling the menu, just
set the Temporary to true when using commandbars.add (as mentioned by "Ji
Zhou [MSFT]").

It was a bit tough for Word application since setting temporary did not work
well Word. In word, menu would get saved in Normal.dot template. (after the
application was uninstalled the menu would still exist unless Normal.dot is
deleted and recreated). To overcome this I create a custom template (via
Automation, using Add method of Word) and added it as a global template, set
customizationcontext to my global template, create my menus, set template
saved property to true and revert customizationcontext to normaltemplate.

Hope this helps


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

We tried that in Word but it would get the menus screwed up with the
normal template, and sometimes would go away if a new template was
brought in.

This info must be in the registry somewhere - anyone know where?

thanks - dave


Hello Dave,

In order to make the custom command bar and controls do not remain in the
Office application after uninstalling the Add-in, we need to create them as
temporary bars or controls. Temporary bars/controls are automatically
deleted when the container application is closed. This behavior is
controlled by CommandBars.Add()/CommandBarControls.Add() functions'
Temporary parameter.

The corresponding document is available here:
http://msdn.microsoft.com/en-us/library/aa141979(office.10).aspx. See the
explanations for the Temporary parameter.

I also write some test codes on my side. It works fine. I uninstall my
Add-in and restart all Office application. My custom command bar and
controls disappear.

Office.CommandBar cb;
Office.CommandBarComboBox edt;
Office.CommandBarButton btn;
Object missing = Type.Missing;

public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
applicationObject = application as Word.Application;

cb = applicationObject.CommandBars.Add("test",
Office.MsoBarPosition.msoBarTop,
false, true) as Office.CommandBar;
cb.Visible = true;
cb.Protection = Microsoft.Office.Core.MsoBarProtection.msoBarNoCustomize;

edt = cb.Controls.Add(Office.MsoControlType.msoControlEdit, missing,
missing, missing, true) as Office.CommandBarComboBox;
edt.Caption = "My Editor";
edt.Tag = "My Editor";

btn = cb.Controls.Add(Office.MsoControlType.msoControlButton, missing,
missing, missing, true) as Office.CommandBarButton;
btn.Caption = "My Button";
btn.Tag = "My Button";
}

Please let me know whether the suggestion works for you or not. And if you
have any concerns or questions on this, please feel free to contact me.


Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
K

Ken Slovak - [MVP - Outlook]

I prefer not to change CustomizationContext, what I do is after any change
to the UI I set CustomizationContext.Saved = true. Then on shutdown while
the UI is still in scope, or on closing an item, I delete the UI I created
and set CustomizationContext.Saved = true again. That way the UI is not
persistent, I don't mess with existing CustomizationContext that some other
app might be depending on and the user doesn't get prompted to save
Normal.dot when they exit if Word is set that way.
 
T

Tony Jollans

If you think that some other app may be relying on the CustomizationContext,
then you are recognising that it might not be NormalTemplate. In this case
what you are doing could mess up the other app at least as much as changing
the context, and might not necessarily do what you want either - you have no
knowledge as to whether the context you add things to is the same one you
later remove them from.

The well-behaved way to do things is to remember the setting, change it for
your own task, and then change it back to what you remembered.

--
Enjoy,
Tony

www.WordArticles.com
 
D

David Thielen

We've decided to stick with what we have as both of those approaches
have problems. With our approach the only downside is that on an
uninstall we tell the user they have to do that part themselves - and
blame Microsoft.


If you think that some other app may be relying on the CustomizationContext,
then you are recognising that it might not be NormalTemplate. In this case
what you are doing could mess up the other app at least as much as changing
the context, and might not necessarily do what you want either - you have no
knowledge as to whether the context you add things to is the same one you
later remove them from.

The well-behaved way to do things is to remember the setting, change it for
your own task, and then change it back to what you remembered.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

\Ji Zhou [MSFT]\

Hello Dave and all,

Thanks for your comments, actually the temporary attribute not working is a
known issue of Word. And it is documented in the following KB article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;212616

And this issue is discussed before in the CSS support service. The
recommended and most users taken way is:

1.Create a non temporary command bar/menu item for Word in the OnConnection
function.
2.Create a temp variable, do a find control and remove the menu in the
OnDisconnection function.
3.Call this.applicationObject.NormalTemplate.Save() to enforce the
Normal.dot to save.

Dave, would you mind to try this approach and let me know whether this works
for you?

Have a good weekend!

Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

We looked at that before but found that if a user changed their
template and did not want it saved, the below set of steps would
invisibly save their changes anyways.

We think it's bad to force a save of all template changes on normal.

thanks - dave


Hello Dave and all,

Thanks for your comments, actually the temporary attribute not working is a
known issue of Word. And it is documented in the following KB article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;212616

And this issue is discussed before in the CSS support service. The
recommended and most users taken way is:

1.Create a non temporary command bar/menu item for Word in the OnConnection
function.
2.Create a temp variable, do a find control and remove the menu in the
OnDisconnection function.
3.Call this.applicationObject.NormalTemplate.Save() to enforce the
Normal.dot to save.

Dave, would you mind to try this approach and let me know whether this works
for you?

Have a good weekend!

Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
T

Tony Jollans

We think it's bad to force a save of all template changes on normal.

I agree - and find it odd that such an approach is 'recommended'. You should
only make changes to your own AddIn.

I don't understand what problems you have setting the CustomizationContext
to your own AddIn and setting its Saved property to true. Unless you make
further changes to it there shouldn't even be a need to remove the
customization on Close because it won't be saved.
 
C

Cindy M.

Hi David,
We looked at that before but found that if a user changed their
template and did not want it saved, the below set of steps would
invisibly save their changes anyways.

We think it's bad to force a save of all template changes on normal.
Why not distribute your own template with your add-in, in the same
application folder. Have your add-in load that when it loads, set that
to be your customization context and save all your toolbar stuff in
it. When your add-in unloads, it also unloads the template.

When the add-in is unistalled, remove the template, as well.

Nothing would ever be saved in something that "belongs" to the user or
any other program.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :)
 
D

David Thielen

We don't want to require a template (one of the reasons we won't touch
VSTO). Much better to just say use Word and we're there.

thanks - dave


Hi David,

Why not distribute your own template with your add-in, in the same
application folder. Have your add-in load that when it loads, set that
to be your customization context and save all your toolbar stuff in
it. When your add-in unloads, it also unloads the template.

When the add-in is unistalled, remove the template, as well.

Nothing would ever be saved in something that "belongs" to the user or
any other program.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :)


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

How do we do that if we have no template?

thanks - dave


I agree - and find it odd that such an approach is 'recommended'. You should
only make changes to your own AddIn.

I don't understand what problems you have setting the CustomizationContext
to your own AddIn and setting its Saved property to true. Unless you make
further changes to it there shouldn't even be a need to remove the
customization on Close because it won't be saved.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
T

Tony Jollans

Sorry, I forgot this was a programming group rather than just a Word one,
but there's no reason your AddIn couldn't have its own template - you could
even create and load a temporary one on the fly - thrown away afterwards, it
wouldn't matter what it contained.
 
C

Cindy M.

Hi David,
We don't want to require a template (one of the reasons we won't touch
VSTO). Much better to just say use Word and we're there.
You don't "require" one - you install one as part of your application.
If it gets deleted, use the Word app to recreate it - it's just an
empty *.dot file, after all. Same principle as installing DLLs and
resources - absolutely no difference.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :)
 
J

Jean Lorieux

Hi,

The answers explain how to create an AddIn which doesn't leave menu after
the uninstall, but for an old AddIn which have already been uninstalled and
for which menu are still present in Office 2003/2007, is there a way to clean
these menus ?
Is there a cache file for the Office GUI or something else we can
remove/modify to clean menu without launching Office Gui, or are we stuck to
the solution explain below (new addin to do the cleanup) ?


Thanks for your help,

Jean L.
 
C

Cindy M.

Hi Jean,
The answers explain how to create an AddIn which doesn't leave menu after
the uninstall, but for an old AddIn which have already been uninstalled and
for which menu are still present in Office 2003/2007, is there a way to clean
these menus ?
Is there a cache file for the Office GUI or something else we can
remove/modify to clean menu without launching Office Gui, or are we stuck to
the solution explain below (new addin to do the cleanup) ?
It really depends on
1. Which application we're talking about
2. In the case of Word, if you know where the toolbars were created

In most Office applications the toolbar definitions are stored centrally, in an
application document file.

I can really only speak about Word, and Word can store them in any document
file. By default, they're saved in the user's Normal.dot template. A
knowledgeable developer will distribute his own template with the add-in and
save them in that. The add-in loads the template when it loads and removes it
when it unloads. But if you want to see whether they've been saved in Normal.dot
just rename Normal.dot to Normal.dot.OLD then start Word. If they toolbar
customizations don't appear, then they've been saved in Normal.dot.

But in order to remove them from the Office document you do have to fire up the
"Office GUI", as you call it. You can't just delete the Office document
containing them because the user will have stored his personal customizations
there.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :)
 
J

Jean Lorieux

Thank you very much for your answer.

That's not very good news for me, but at least, I know now what I can and
cannot do.

Jean L.
 

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