Word 97 button events in managed code

T

tartancli

Hi,

I have a number of Word COM add-ins which are working in Word 2003 and
Word2000. I'm now porting these to Word 97 and have run into some problems.
Since Word 97 does not support COM add-ins as such, i am using a COM
callable wrapper, called from AutoExec VBA macro. This wrapper then calls the
"OnConnection" method, which calls OnStartupComplete. In OnStartupComplete,
i have some simple code to add a button to the Standard toolbar and add an
event handler for this button. (Part of) This code is as follows:


myButton.OnAction = "!<MyAddin.Connect>";

myButton.Visible = true;
myButton.Click += new
Office._CommandBarButtonEvents_ClickEventHandler(this.myButton_Click);

This works for 2003, and 2000. However, for Word 97, the Office
CommandBarButton does not have a Click attribute. (MSO97.dll) .

I have found some document through google that suggests that the line

myButton.OnAction = "!<MyAddin.Connect>";

should be sufficient to set up the handler. However, i get an exception when
setting this (and subsequently, the button click doesn't fire any event). The
exception is endSystem.Runtime.InteropServices.COMException (0x80004005) :
Unspecified Error commandBarButton.set_onAction.

If anybody has any suggestions as to why i get this exception, and/or how to
set up button event correctly I'd be most grateful. Thanks.
 

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