Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

DocumentChange event: microsoft bug?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gandalf - 16 Feb 2005 10:31 GMT
FOR WORD XP

Has anyone noticed anything strange in the DocumentChange event?

I have an addin which is catching this event, and it is fired too
often: it is supposed to fire when a new doc is created, an existing
one ic closed or another document gets focus, but in my case it is
fired also when i update fields in table or headers, lor when i add
tables, etc.

Thanks
Tom Winter - 16 Feb 2005 14:31 GMT
You  might want to check out the other events then. DocumentOpen,
NewDocument and WindowActivate might do what you need.

Signature

Tom Winter
tom@nospam.amosfivesix.com

> FOR WORD XP
>
[quoted text clipped - 7 lines]
>
> Thanks
gandalf - 17 Feb 2005 09:01 GMT
> You  might want to check out the other events then. DocumentOpen,
> NewDocument and WindowActivate might do what you need.
[quoted text clipped - 10 lines]
> >
> > Thanks

No we cannot, unfortunately.
In addition we have some macros from another company to integrate
tehir product with Word, and those macros are catching the
DocumentChange event, and they are firedd when not needed. since this
macros requires a connection to the DB, each time I update a doc
containing 30 fields, 30 DB connections are made one after the other,
slowing down Word to death
Tom Winter - 17 Feb 2005 14:17 GMT
>> You  might want to check out the other events then. DocumentOpen,
>> NewDocument and WindowActivate might do what you need.
[quoted text clipped - 18 lines]
> containing 30 fields, 30 DB connections are made one after the other,
> slowing down Word to death

I assume you are not able to change the macros? If that's the case, there's
not much more I can help you with. I myself have never used the
DocumentChange event, so I'm not familiar with any problems related to it.
Signature

Tom Winter
tom@nospam.amosfivesix.com

Peter_A_M (NL) - 22 Feb 2005 10:09 GMT
For myself I'd try to work with a public variable as a "flag"
(e.g. declaration in module: Public FlagDBConnected as Boolean).
You could set this variable to True once your DB is connected so that your
code needs not try to do this anymore.
Remains the problem to decide when (& where & how) to set the variable to
False again.

Peter
Jean-Guy Marcil - 17 Feb 2005 16:55 GMT
gandalf was telling us:
gandalf nous racontait que :

>> You  might want to check out the other events then. DocumentOpen,
>> NewDocument and WindowActivate might do what you need.
[quoted text clipped - 22 lines]
> containing 30 fields, 30 DB connections are made one after the other,
> slowing down Word to death

See Pete Benett's solution for something like this:
   http://tinyurl.com/6rfuf

Also, according to
   http://msdn.microsoft.com/library/default.asp?url=/library/en-us/off2000/html/wo
evtdocumentchange.asp

the document change event fires only in certain circumstances. If you get a
different behaviour, then it may be that the third party add-in you are
using was badly designed and doing things in the background that are not
visible but that meet with the criteria for firing a DocumentChange event.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

gandalf - 18 Feb 2005 13:28 GMT
> Also, according to
>     http://msdn.microsoft.com/library/default.asp?url=/library/en-us/off2000/html/wo
evtdocumentchange.asp

> the document change event fires only in certain circumstances. If you get a
> different behaviour, then it may be that the third party add-in you are
> using was badly designed and doing things in the background that are not
> visible but that meet with the criteria for firing a DocumentChange event.

Forgot one thing: I don't have this problem with Word97, but only with
WordXP...
It must be a bug: why the DocumentChange event should fire when i
update the fields of a document?
Jean-Guy Marcil - 18 Feb 2005 16:22 GMT
gandalf was telling us:
gandalf nous racontait que :

>> Also, according to
>>
[quoted text clipped - 12 lines]
> It must be a bug: why the DocumentChange event should fire when i
> update the fields of a document?

I tested the DocumentChange event on Word XP and Word 2003.

It behaved exactly as it was supposed to. I inserted tables, deleted them,
opened/closed headers with/without fields, updated fields in headers/tables,
mailmerged, etc.
No problem.

This is why I suggested that either there is something in your code that you
have not considered that fires the event, or the third-party add-in is doing
stuff you do not know about (do you have access to the code?) or your
template is corrupt.

OTHO, I have not tested it with a DB connection.
If there is a bug, can you narrow it down and provide a step by step
procedure so that others can reproduce it?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Michael Schmidt - 26 Feb 2005 01:08 GMT
> gandalf was telling us:
> gandalf nous racontait que :
[quoted text clipped - 31 lines]
> If there is a bug, can you narrow it down and provide a step by step
> procedure so that others can reproduce it?

Maybe the easiest thing is to include a workaround into the
Document_Change procedure:

Declare the sub as static or declare a variable on class level in
which you enter the Name of the document that caused the call of the
Document_Change sub. If it is the same as the time before, ignore the
event:

Public WithEvents MSWord As Application

Private Static Sub MSWord_DocumentChange()

 Dim LastDoc As String
 
 If ActiveDocument.Name = LastDoc Then
   Exit Sub
 Else
   LastDoc = ActiveDocument.Name
 End If

 ' Body of proc ...

End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.