Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Sep 2004
    Location
    Sydney, New South Wales, Australia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checking if a file is open (Word 2000 sp3)

    I have a series of templates that create various documents, each document has macros that read and write information to a text file (Response.ini) using the 'PrivateProfileString' command. The templates are to be used on a small network and there is a possibility (although small) that two documents might try to use the 'Response.ini' file at the same time. I do not want the 'ini' file to get corrupted or a read/write operation to fail.

    How do I test to see if the 'ini' file is being accessed by another document?

    I have tried using a User Function that uses the Open statement and return true or false. If I have the 'ini' file open in Notepad the Function tells me that the ini file is not open.

    Any pointers to solve my problem?

    Thanks

  2. #2
    Star Lounger
    Join Date
    Sep 2004
    Location
    Sydney, New South Wales, Australia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Checking if a file is open (Word 2000 sp3)

    Hi Hans
    Thanks for the information. I will check my code with the ini file opened in Word.

    Again thanks for the info and quick reply.

    Regards

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Checking if a file is open (Word 2000 sp3)

    Notepad doesn't lock a file it has open. I assume that PrivateProfieString does lock the ini file when you set a value (probably not when you read a value), so you might use the test with Open before setting a value. Or you might just take the risk of not checking - operations on ini files are extremely fast.

Posting Permissions

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