Results 1 to 4 of 4

Thread: Detecting in-use documents

  1. #1
    Guest

    Question

    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

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    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.
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  3. #3
    Guest
    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 :{{)}

  4. #4
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    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.
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width