+ Reply to Thread
Results 1 to 5 of 5

Check read-only status, and if locked - skip all code and give a message box

  1. #1
    Registered User
    Join Date
    03-01-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    49

    Check read-only status, and if locked - skip all code and give a message box

    Good Day,

    I have the following code that opens up a file ARCHIVE.xlsb.

    Please Login or Register  to view this content.
    I need to check the file status before opening it, as someone else could be using it.

    If the file is LOCKED, I need it to skip all the additional code and give me a message as follow: "Please retry in 5 seconds..."

    I have tried multiple codes already - an goto error seems to be an option - But I cannot get it to work...

    Any assistance will be greatly appreciated.

    JEDEMEYER1

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Check read-only status, and if locked - skip all code and give a message box

    You could try to do a low level file open... The Operating System will throw an error if any other user, or process, has the file open.

    Add the following to a module:
    Please Login or Register  to view this content.
    And change your code to :
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-01-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: Check read-only status, and if locked - skip all code and give a message box

    Hi cytop,

    No unfortunetlay it still does not work I did as you said, and it still ignores the read only status of the archive file.

    I have it opened on another computer (This making it Read Only), and when I run the code it just does the whole thing, without stopping.

    I am giving you my entire code:

    Please Login or Register  to view this content.
    I hope it helps you in finding out what I did wrong where.

    Please.

    JEDEMEYER1

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Check read-only status, and if locked - skip all code and give a message box

    Apologies, I had a typo in a couple of variable names... This version tested to return True when the original version returned False...

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-01-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: Check read-only status, and if locked - skip all code and give a message box

    Thank You cytop!

    Works like a charm.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy and paste locked cells, and have pasted cells retain LOCKED status.
    By stratloveslenny in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2014, 03:05 PM
  2. [SOLVED] Code to give message if Filtered value not found in data
    By dinesh_ltjd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2013, 12:12 PM
  3. Need a vba code to check the status and based on rules calculate service years
    By baba_excel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-19-2012, 09:03 PM
  4. if locked for editing message box comes up auto select read-only
    By 2funny4words in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2009, 01:38 PM
  5. How to check Read Only status for active workbook
    By stoney1977 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-31-2008, 05:55 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1