Losing Word events

D

David Thielen

Hi;

We have always had a problem where we sometimes lose the events for our
items we added to the Word menu. This is not the problem of using local
variables for the menu objects - we use global variables. And 95% of the time
we never lose the events even if the user is running Word for hours.

We can consistently make the problem happen if we open 2 instances of Word
2003 and then close the first one.

Any suggestions on how to work around this? Our AddIn is still loaded but
users can't access it.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Jialiang Ge [MSFT]

Hello Dave,

From your post, my understanding on this issue is:
You have a Word add-in (something like a command in Word menu), when you
open 2 instances of Word and close the 1st one, the 2nd Word instance's
add-in losses its user events.
If I'm off base, please feel free to let me know.

Since you said such condition happens when the 1st Word instance is closed,
I suggest you check your addin's OnDisconnection event where most of your
resources and variables are released. Pay attention to the shared
variables. My guess is that you release such variables in OnDisconnection
event yet the add-in of the 2nd instance of Word is still in need of them.

If my suggestions above cannot help you solve the problem, would you give
me some sample codes so that I can reproduce the issue.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
to the limited number of phone-based technical support incidents. Complex
issues or server-down situations are not recommended for the newsgroups.
Issues of this nature are best handled working with a Microsoft Support
Engineer using one of your phone-based incidents.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hello Dave,

I feel sorry for my misleading. The event OnDisconnection fires only when
the application is closed (not when a document is closed).

But I still suggest that you check the handlers for Document object's Close
event if you confirm that the problem ONLY occurs when one of the open
document is closed. The close event can be "DocumentEvents_Event_Close".
For instance:

Word.DocumentClass doc =
(Word.DocumentClass)this.applicationObject.ActiveDocument;
doc.DocumentEvents_Event_Close += new
Word.DocumentEvents_CloseEventHandler(doc_DocumentEvents_Event_Close);
void doc_DocumentEvents_Event_Close()
{
MessageBox.Show("Document Close");
}

In your scenario, When the 2nd word document is opened, it will check Word
process first. If the process already exists (due to the 1st word
document), it will be attached to the process instead of creating a new
one. Therefore, it is very likely that the newly opened document will
unexpectedly modify some Word add-in's shared attributes or variables set
by the 1st word document due to carelessness.

I sincerely hope the suggestions above can help you find out the problem.

Have a nice day! :)

Best regards
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

I get BeforeClose:
ApplicationEvents3_Event aee = (ApplicationEvents3_Event)applicationObject;
aee.DocumentBeforeClose += new
ApplicationEvents3_DocumentBeforeCloseEventHandler(Event_DocumentBeforeClose);

but that code does not touch the menus. Also, if I open docA then docB, then
close docB docA's menus still work. But if I open docA, then docB, and then
close docA I get the problem.

We also have a problem that setting the CommandBarButton.Enabled property on
existing menu items causes an exception sometimes. We wrap that call in a
try/catch and re-set the menu to fix that problem. But this problem could be
related.

This also generally happens when exiting one copy of Word when others are
open or closing the document but leaving Word running so it has no document
in it.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Jialiang Ge [MSFT]

Hello Dave,

Thank you for you information provided in your latest message. :) But it's
still difficult for me to reproduce your issue. :(
Would you please paste your core codes that you set and release the menu
object here?, so that I can have an in-depth and more specific view of how
your problem occurs.

If you feel it inconvenient to paste codes here, the following url links to
a demo of building an addin for Office. It demonstrate how to build a menu
object for office and uses a global variable for the object as you does.
Thus I think it's quite same as your scenario. Would you compare your codes
with it and see what makes the differences, what results in your problem.
http://msdn2.microsoft.com/en-us/library/aa159658(office.11).aspx

Best regards,

Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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