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.