Word Add-in, but user has Word close a document

Add-in Express™ Support Service
That's what is more important than anything else

Word Add-in, but user has Word close a document
 
John Webb




Posts: 7
Joined: 2004-12-08
I have created a Word Toolbar using Add-in Express and everything is working fine with one exception. If the user opens a document using my toolbar, then closes it by using the WORD document close X (upper right hand corner of Word), that leaves buttons on my toolbar in states that I really don't want them in. Is there anyway my toolbar code can tell if the document it opened has been closed by Word, so I can then set the buttons the way they should be?
Posted 11 Mar, 2005 18:25:58 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi John.

You can change states of controls on your command bar via the NewDocument, DocumentOpen and DocumentBeforeClose event in the ADXWordAppEvents component.
Posted 12 Mar, 2005 03:51:07 Top
John Webb




Posts: 7
Joined: 2004-12-08
I went to the DocumentBeforeClose event and it contained this:

Public Sub DocumentBeforeClose(ByVal doc As Object, ByRef cancel As Boolean) Implements IWordAppEvents.DocumentBeforeClose

Marshal.ReleaseComObject(doc)
end sub

I tried to add this to the event but it wouldn't accept it:

AdxCommandSaveDocButton.Enabled = False
AdxCommandStudyListBtn.Enabled = True

It said it required an Object reference and I could not figure out what object to reference it to.

I am obviously doing something wrong, can you tell me what it is?

Thanks
Posted 16 Mar, 2005 17:50:12 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi John.

Why don't you use the ADXWordAppEvents component? Just add this component to the addinmodule and put your code into the DocumentBeforeClose event handler.
Posted 17 Mar, 2005 06:29:47 Top
John Webb




Posts: 7
Joined: 2004-12-08
That did the trick. I wasn't aware of the ADXWordAppEvents component.
Posted 17 Mar, 2005 16:52:31 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi John.

The fact is, that now we are preparing the ADX documentation and some ADX features have not added in the current ADX help. To add the ADXWordAppEvents component you just need to right click on an addinmodule and choose the "Add Events" option.
Posted 18 Mar, 2005 04:17:12 Top