DocumentChange event is fired when dialogs pop up

S

Stamppot

Hi,

I'm using the DocumentChange event to handle stuff when I'm changing between
documents, loading or creating a new document. I use forms for different
stuff, and when opening a form or any form of dialog (e.g. MessageBox), and
the focus is returned back to the same document, the DocumentChange event is
fired. How can I avoid this behavior such that it only fires (or checks) when
changing from a document to another document?

Strangely enough, this also results in forms being popped up again a number
of times (usually from 2-5 times) when pressing either Ok or Cancel.

Thanks,

Jens
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?U3RhbXBwb3Q=?=,
I'm using the DocumentChange event to handle stuff when I'm changing between
documents, loading or creating a new document. I use forms for different
stuff, and when opening a form or any form of dialog (e.g. MessageBox), and
the focus is returned back to the same document, the DocumentChange event is
fired. How can I avoid this behavior such that it only fires (or checks) when
changing from a document to another document?

Strangely enough, this also results in forms being popped up again a number
of times (usually from 2-5 times) when pressing either Ok or Cancel.
Create a (global) object variable and assign the current document object to it.
When the event fires, compare the object that it returns with your variable,
testing to see if they're the same document. If they are, just "drop through"
without executing your code.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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