Microsoft KB Archive/313948

= Word loses reference to COM object menu items (CommandBarControl) =

Article ID: 313948

Article Last Modified on 1/31/2007

-

APPLIES TO


 * Microsoft Office Word 2003
 * Microsoft Word 2002 Standard Edition

-



This article was previously published under Q313948





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 &quot;Applies to&quot; section.

Additional query words: VBE VBA WD2002 WD2003

Keywords: kbbug kbpending KB313948

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.