Discussion:
Events not getting bound to buttons for new Word documents
(too old to reply)
Vincent Croft
2005-09-21 17:09:04 UTC
Permalink
I am writing a generic Office 2003 AddIn in .NET that creates a toolbar and
menu. The toolbar/menu items are bound to events handlers of type
_CommandBarButtonEvents_ClickEventHandler.

For Powerpoint and Excel everything is fine. However, for Word when a new
document is opened, the toolbar and menu items do not seem to get bound to
the events. I think this is probably a result of the the non mdi nature of
Word.

I can't find any documentation about this or how to work around it.

Is it a known issue (aka 'feature'?)

I have tried to work around it by removing and rebinding the events each
time a document loses/gains focus but this is not as straightforward as you
might imagine and in some scenarios event handlers get bound up twice
resulting in 2 events firing rather than one.

Any help or guidance would be much appreciated.
Jezebel
2005-09-22 08:27:09 UTC
Permalink
It depends on

a) the CustomizationContext in which you define the binding, and
b) whether you have other add-ins (such as Acrobat 6) that interfere with
settings
Post by Vincent Croft
I am writing a generic Office 2003 AddIn in .NET that creates a toolbar and
menu. The toolbar/menu items are bound to events handlers of type
_CommandBarButtonEvents_ClickEventHandler.
For Powerpoint and Excel everything is fine. However, for Word when a new
document is opened, the toolbar and menu items do not seem to get bound to
the events. I think this is probably a result of the the non mdi nature of
Word.
I can't find any documentation about this or how to work around it.
Is it a known issue (aka 'feature'?)
I have tried to work around it by removing and rebinding the events each
time a document loses/gains focus but this is not as straightforward as you
might imagine and in some scenarios event handlers get bound up twice
resulting in 2 events firing rather than one.
Any help or guidance would be much appreciated.
Vincent Croft
2005-09-22 08:41:02 UTC
Permalink
Thanks for responding.

The CustomizationContext is the default (normal.dot) as some commands are
available when no documents are open. I have no other add-ins loaded that
could get in the way.

Vincent.
Post by Jezebel
It depends on
a) the CustomizationContext in which you define the binding, and
b) whether you have other add-ins (such as Acrobat 6) that interfere with
settings
Post by Vincent Croft
I am writing a generic Office 2003 AddIn in .NET that creates a toolbar and
menu. The toolbar/menu items are bound to events handlers of type
_CommandBarButtonEvents_ClickEventHandler.
For Powerpoint and Excel everything is fine. However, for Word when a new
document is opened, the toolbar and menu items do not seem to get bound to
the events. I think this is probably a result of the the non mdi nature of
Word.
I can't find any documentation about this or how to work around it.
Is it a known issue (aka 'feature'?)
I have tried to work around it by removing and rebinding the events each
time a document loses/gains focus but this is not as straightforward as you
might imagine and in some scenarios event handlers get bound up twice
resulting in 2 events firing rather than one.
Any help or guidance would be much appreciated.
Jezebel
2005-09-22 09:23:54 UTC
Permalink
Have you verified that the changes are, in fact, being saved into
normal.dot?
Post by Vincent Croft
Thanks for responding.
The CustomizationContext is the default (normal.dot) as some commands are
available when no documents are open. I have no other add-ins loaded that
could get in the way.
Vincent.
Post by Jezebel
It depends on
a) the CustomizationContext in which you define the binding, and
b) whether you have other add-ins (such as Acrobat 6) that interfere with
settings
Post by Vincent Croft
I am writing a generic Office 2003 AddIn in .NET that creates a toolbar and
menu. The toolbar/menu items are bound to events handlers of type
_CommandBarButtonEvents_ClickEventHandler.
For Powerpoint and Excel everything is fine. However, for Word when a new
document is opened, the toolbar and menu items do not seem to get bound to
the events. I think this is probably a result of the the non mdi nature of
Word.
I can't find any documentation about this or how to work around it.
Is it a known issue (aka 'feature'?)
I have tried to work around it by removing and rebinding the events each
time a document loses/gains focus but this is not as straightforward as you
might imagine and in some scenarios event handlers get bound up twice
resulting in 2 events firing rather than one.
Any help or guidance would be much appreciated.
Vincent Croft
2005-09-22 11:55:02 UTC
Permalink
The changes are only made temporarily, i.e. do not get saved.

I seem to have made this work now by removing and reattaching the event
handlers to the events each time a document loses and regains focus or gets
closed. It has proved quite difficult given that it has to work differently
for other apps and that Word does act like an MDI when there are no documents
open. I have the impression that even though the toolbars are global, each
document's button needs to have an event handler attached separately. If this
is true, ideally I would keep a collection of buttons for each document but
this would interfere too much with the way things work for the other office
apps.

Thanks for your help.
Post by Jezebel
Have you verified that the changes are, in fact, being saved into
normal.dot?
Post by Vincent Croft
Thanks for responding.
The CustomizationContext is the default (normal.dot) as some commands are
available when no documents are open. I have no other add-ins loaded that
could get in the way.
Vincent.
Post by Jezebel
It depends on
a) the CustomizationContext in which you define the binding, and
b) whether you have other add-ins (such as Acrobat 6) that interfere with
settings
Post by Vincent Croft
I am writing a generic Office 2003 AddIn in .NET that creates a toolbar and
menu. The toolbar/menu items are bound to events handlers of type
_CommandBarButtonEvents_ClickEventHandler.
For Powerpoint and Excel everything is fine. However, for Word when a new
document is opened, the toolbar and menu items do not seem to get bound to
the events. I think this is probably a result of the the non mdi nature of
Word.
I can't find any documentation about this or how to work around it.
Is it a known issue (aka 'feature'?)
I have tried to work around it by removing and rebinding the events each
time a document loses/gains focus but this is not as straightforward as you
might imagine and in some scenarios event handlers get bound up twice
resulting in 2 events firing rather than one.
Any help or guidance would be much appreciated.
Loading...