PDA

Click to See Complete Forum and Search --> : Detecting in-use documents


Dec 20th, 2000, 07:32 PM
Thought this would be easy, but it's not...

I'm opening a document with Word through VB automation:

wrdApp.Documents.Open filename, etc.

But I cannot figure out how to tell if someone else already has it opened. Currently, I have to check to see if the caption property has the word "(copy)" in it, but this is obviously not a good long-term strategy. Unfortunately, because this is a 'copy' the read-only property of the doc is set to false, so I can't check that.

Any help appreciated, thanks,
AD :eek:

RealisticGraphics
Dec 23rd, 2000, 08:52 AM
Well if I understand you right you have a document that is read only so you can't check the readonly property effectively. Try making your read only document into a Word Template. This way when they save the document it'll ask to save as a new document. This may not be what you want but it may help you out.

Dec 27th, 2000, 10:38 AM
Thanks for the reply.

I think the real problem is that when I open the doc through automation it never tells me somebody has it open. It automatically goes out and creates a copy, then loads that.

One thing I did not mention is that this is all going on in the background (it's a printing program) so the user never sees Word (visible property set to false), so they (and I) don't realize this is a copy.

Thanks,
Adam Di Gleria :{{)}

RealisticGraphics
Dec 30th, 2000, 09:43 AM
Ok then what about a real round-about way of doing this. Create a text file on the server (or someplace) and before your program goes to print it you write something to the file for example:

Your program runs, now before it does anything with the document it checks to see if this file exists (we'll call it CheckRunFile.txt just for the example). If the file exists then it opens that text file and looks at it.

If it reads 1 then the file is already open and the program lets the user know that it is in use elsewhere. If it is a 0 then the file is not in use and then the program replaces the file is an updated version writing a 1 in the 0 spot and then uses the document.

Then write some code so that if the file is not there it creates it and updates the file with the appropriate info.

If you need any other help or code examples let me know.