I tried using the command:
If Dir(strFilePath & "~$" & strfilename, vbHidden) <> "" Then
'Skip file
End if
to use the "~$" file to determine if it's open. This worked fine on my PC.
However, when I tried it on the network, it didn't work.
I need to be able to determine if a file is open, either by using Dir(), or
by using some method within Word. Since the files are open across a network,
I can't check the open documents in my copy of Word. Any ideas? Using Word
2000.
Thanks!
Neil
This is a way doing it:
Function DocIsOpen(strFullName As String)
Dim wrdDoc As Word.Document
Dim blnResult As Boolean
For Each wrdDoc In Word.Documents
If StrComp(wrdDoc.FullName, strFullName, vbTextCompare) = 0 Then
blnResult = True
Exit For
End If
Next
DocIsOpen = blnResult
End Function
You can use this function in this way:
docisopen("D:\Data\Discussieforum\Test\test.doc")
so use the fullname.
Jan
"jan" <j...@releerf.nl> wrote in message
news:ei6DdQyG...@TK2MSFTNGP03.phx.gbl...
See http://www.word.mvps.org/FAQs/MacrosVBA/CheckIfFileOpen.htm
Hope this helps.
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
"Neil" <nos...@nospam.net> wrote in message
news:YASVi.3528$Vx3....@nlpi069.nbdc.sbc.com...
I suppose I can turn error handling on at the beginning of the process and
then off again at the end (which would be OK as long as it didn't crash in
the middle). So, if I have to, I'll do that. Still, a solution that didn't
require error handling to be on would be better still.
Any idea why my original Dir() solution worked on my local machine to find
the ~$ file, but didn't work across the network?
Thanks!
Neil
"Shauna Kelly" <Shaun...@SendNoSpamToShaunaKelly.com> wrote in message
news:%23uQF8i4...@TK2MSFTNGP02.phx.gbl...
Try this
How to check if a file has already been opened by another user
http://www.word.mvps.org/FAQs/MacrosVBA/CheckIfFileOpen.htm
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup