When can I be sure my Word doc is really closed?

H

Hal Tz

I have a VB app that opens a doc in Word, then hangs around waiting for it to
close, calling this periodically:
------------------------------------------------------------
(oWD is Word.Application, already instantiated )

Function IsDocOpen (sName as string) as Boolean
Dim doc As Document
IsDocOpen = False
For Each doc In oWD.Documents
If (InStr(sName, doc.Name)) Then
IsDocOpen = True
GoTo endit
End If
Next doc
endit:
end function
------------------------------------------------------------
Once the file is closed, I need to copy the (potentially) modifed file
elsewhere. IsDocOpen works fine, but there are occasional instances (never
on my machine, of course) where the copy yields the old version of the file.
I'm guessing the file is not really closed yet when Word says it is. I've put
plenty of debug statements everywhere but have come up empty. I have also
(just today, I have no results yet), put in a call to a C++ function that
uses CFile to open the file exclusively, which in a simple test program fails
if word has it open and suceeds if not. Wondering if anyone had any other
ideas. Thanks.
-
Hal
 
C

Cindy Meister

What are the chances that the user has saved it to a different location
(File/Save As)?

-- Cindy
 
H

Hal Tz

none..these are my testers, and they don't vary from the script, which says
to always save the file with the same path and name.
 
C

Cindy Meister

none..these are my testers, and they don't vary from the script, which says
to always save the file with the same path and name.
<sigh> It can never be the obvious, easy answer, can it? (Or if it is, one
doesn't ask the question, so it goes round in circles because of that.)

FWIW, the only time I've ever seen anything even resembling what you report
is when user has opened a file directly from, say, an Outlook email message.
They'll work, save assiduously, close... and all the changes are lost,
because the file they were saving to was a TEMP file that was destroyed when
the document was closed. (This, from personal experience living in a
household with someone who's a durn good beta tester - can break anything
without even trying.)

Other than that, there's been the occasional "murmer" here in the NGs where
users have complained on occasion that this is happening. Unfortunately, I
can't recall the Windows+Word combination where that was happening (if those
people ever did respond and tell us). But those reports were very few, and
very far between...

If you're seeing this consistently, though, then I have to suspect something
in how your application is working with Word, or a system configuration
problem. Some kind of "management" software or anti-virus software, for
example, that might be interfering with the file management. Is there
anything of this nature installed? If you boot a system where this is
happening all the time in Safe Mode, does it still occur?

-- Cindy
 
H

Hal Tz

thanks for the thoughts..it will take quite a while to eliminate other apps
as potential culprits, and also to get the machines where this is happening
OCCASIONALLY (darn!) into Safe Mode. I'll get back to you. Thanks again!
 

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