Detect if a word document is open

Hello, i’ve wasted many days trying to figure out how can i detect via lotus script if a specific word document is open in the same computer where Notes is running. I found that OLE can detect if word application is running and through a loop i could see what documents are opened in that instance of word…but if i had more instance of word running at the same time…the getObject(“”, “Word.Application”) retrieves just the firs one encountered!! In other words…it can’t be possible to loop through word instances. Neither Windows API helped me 'cause i didn’t find a CloseFile method or something similar…Is there a wizard out there that knows the trick???

Thanks in advance, Daniele.

Subject: Detect if a word document is open

If you know the directory and filename (eg. users temp directory) you could try checking for a open Word file. If you do not know the specific path of the file, I think it’s worse…

tempDir = Environ( "TEMP" )

filename = "document1.doc"

strTest = tempdir & "\~$" & Mid$(filename, 3)

if (strTest = "") then

	Call Object.ExtractFile( tempDir & "\" & filename)

else

	'Already open

End if

Subject: RE: Detect if a word document is open

Mmmhh that’s a good idea …to check if there’s the temporary file of the doc word…anyway…let’s susppose i manage to check if it’s open…the second and main problem is that i don’t know how to close it…that’s a thing i’d like to do when user close notesdocument and forget to close word that is attached in it and that he has opened…anyway…i could also warn him with a message and stop the exit procedure…

Subject: Detect if a word document is open-Solution

As ususal…solution comes in mind when you don’t think anymore about it…as i told i use getObject(“”, “Word.Application”) to get if word is running…well…if you manage to check if a word is open…then you can use getObject(“c:\yourdoc.doc”) and …voilà…you have an handle to it and so you can use OLE to close it…i tested and it works…well i post if someone need an advice.

Bye, daniele.

Subject: RE: Detect if a word document is open-Solution

Great… I was thinking in the same direction, but didn’t get around to test it. As you state, I use it to give users warnings - amongst other things. Maybe I 'll advance a bit and actually close it for them :slight_smile: