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

    Open File ReadOnly (03)

    This most likely has been covered here before but I could not find it using the search feature.

    I have a file that is already opened by someone and I would like VBA code to open the same file as ReadOnly.

    Thanks,
    John

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

    Re: Open File ReadOnly (03)

    Just open the workbook using Workbooks.Open. It will automatically be opened as read-only if someone else has already opened it, no special code needed.

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

    Re: Open File ReadOnly (03)

    Hans,

    This is the error message I receive if someone has the file open and I try to open it while it is still in use.

    John

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

    Re: Open File ReadOnly (03)

    Try inserting

    Application.DisplayAlerts = False

    before, and

    Application.DisplayAlerts = True

    after the instruction that opens the workbook.

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

    Re: Open File ReadOnly (03)

    Hans,

    It did not work.

    John

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

    Re: Open File ReadOnly (03)

    Use the code from the thread starting at <post:=590,293>post 590,293</post:> to test whether the file is already open, and if so, open it read-only:

    Workbooks.Open FileName:="...", ReadOnly:=True

    If that doesn't work either, I'm out of ideas.

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

    Re: Open File ReadOnly (03)

    Hans,

    I'm going to chalk this one up to a corrupted workbook. I started from a blank one and it worked.

    Thanks for your suggestions,
    John

Posting Permissions

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