Word loses reference to COM object menu items (CommandBarControl)

Support for Office 2003 has ended

Microsoft ended support for Office 2003 on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

This article was previously published under Q313948
This article has been archived. It is offered "as is" and will no longer be updated.
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
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.
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.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
VBE VBA WD2002 WD2003

Article ID: 313948 - Last Review: 01/06/2015 07:57:28 - Revision: 3.2

  • Microsoft Office Word 2003
  • Microsoft Word 2002 Standard Edition
  • kbnosurvey kbarchive kbbug kbpending KB313948