Word loses reference to COM object menu items (CommandBarControl)

Article translations Article translations
Article ID: 313948 - View products that this article applies to.
This article was previously published under Q313948
Expand all | Collapse all

SYMPTOMS

When you add a menu item to Microsoft Word from a Visual Basic COM add-in by using the steps in the following article or by using a similar method, the menu item does not work as expected:
238228 How to build an Office 2000 COM add-in in Visual Basic

CAUSE

This problem occurs because Word requires the menu item to be unique. If the menu item is not unique, Word loses its reference to the CommandBarControl object.

Only Word has this requirement. Microsoft Excel and Microsoft PowerPoint do not. Therefore, if you use the same code to add controls in PowerPoint and Excel, the code works as expected.

RESOLUTION

The following resolution comes verbatim from the top of page 319 in the Microsoft Office XP Developers Guide (Microsoft Press, ISBN 0-7356-1242-0):
If your add-in will run in Word, you must also set the Tag property for the CommandBarButton object to a unique String value. This makes sure the command bar button will respond to the Click event and load the add-in for each new document window that the user opens. Because the Tag property provides you with additional information about the control, it is a good idea to set the Tag property for a command bar button that loads a COM add-in in any host application.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Properties

Article ID: 313948 - Last Review: January 31, 2007 - Revision: 3.2
APPLIES TO
  • Microsoft Office Word 2003
  • Microsoft Word 2002 Standard Edition
Keywords: 
kbbug kbpending KB313948

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com