Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Test For File Open (03)

    I know how to test to determine if a file is open. What I would like to do is utilize the Task Scheduler (every 2 hours) to open "File 123" and run some code. If for some reason "File 123" is remains open; the next scheduled task would open the file again (Note! is is still open and it is "read-only"). Is there some way to capture the status on "File 123" the second time around? One receives a message that you can open the file in "read-only". This way I would be able to test the status and immediately close the new Excel application.

    I hope this makes sense as it has been one of those days.

    Thanks,
    John

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

    Re: Test For File Open (03)

    See XL2002: Macro Code to Check Whether a File Is Already Open (applies to other versions of Excel too).

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Test For File Open (03)

    Hans,

    That code determines if the file is open by another user.

    How about the "same user"? If I open the same file on the server I receive the "File in Use" warning along with the prompt to open it in 'read-only', notify or cancel. If I can somehow capture this, open the second file in read-only and at this point I can envoke code to immediately close the second instance of Excel without running any additional code.

    Regards,
    John

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

    Re: Test For File Open (03)

    You shouldn't take the "other user" too literally. The code also detects if the file has been opened by the same user in another instance of Excel.

Posting Permissions

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