+ Reply to Thread
Results 1 to 3 of 3

Set Read-Only status via Macro, doesn't persist.

  1. #1
    Registered User
    Join Date
    03-08-2017
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Set Read-Only status via Macro, doesn't persist.

    Hi all,

    I've written a macro to password protect a worksheet and convert the workbook to Read-Only. It seems to work fine, but after the file is closed, the Read-Only status doesn't stay put. Logically this makes sense to me as the file isn't saved once the read-only status is set, but it can't be saved because it is read-only. Am I missing something simple here? Code below

    Please Login or Register  to view this content.
    Thanks in advance
    Last edited by mashphat; 01-16-2020 at 08:22 AM. Reason: mark as [solved]

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Set Read-Only status via Macro, doesn't persist.

    There are two kinds of read-only. Your code indicates that the file is open in Excel in read-only mode. This is not a persistent state for the file. It is only significant while the file is open in this instance of Excel. You can try this
    Please Login or Register  to view this content.
    but I have not tested it.

    If you want the Windows file system attribute to be read-only, then a different approach is needed.

    Please Login or Register  to view this content.
    Can you clarify what you need to do?
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-08-2017
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Set Read-Only status via Macro, doesn't persist.

    Sure, essentially what I have is a calculation spreadsheet that will have data added over the course of a week or so. Once we're done with editing it will be accessed by multiple people across departments. A small accidental edit would be near impossible to spot, so we fully protect them and make them read-only.

    I'm starting with an open file in Read-Write mode which is password protected. It has some cells locked (containing formulae) and others unlocked - to allow entering of data.

    The code above is attached to a macro button, which is to be pressed when all data has been entered.

    The macro should then unprotect the sheet, lock all cells, re-protect the sheet, then save and convert to Read-Only.

    The reason I didn't go with Save As was that the user would then have to manually delete the Read-Write version afterwards - users skipping steps is the reason for automating this process in the first place.

    I'll try your second suggestion and see if that does the job. Thank you

    EDIT: The second suggestion seems to have done the trick. Thanks for your help.
    Last edited by mashphat; 01-16-2020 at 08:24 AM. Reason: solution worked

+ 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. Formula to Read Values and Insert Status
    By Mizzou.2018 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-07-2019, 12:48 PM
  2. 'Do While' doesn't check for status until it loops?
    By Marandopsu in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-19-2016, 02:43 PM
  3. [SOLVED] Why doesn't status bar update consistently?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 11-08-2015, 06:32 PM
  4. Macro doesn't read .XML file
    By guimassochin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-06-2014, 06:48 AM
  5. Hiding Tabs and Macro doesn't read
    By o4008 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-20-2011, 01:30 PM
  6. [SOLVED] Why doesn't status bar update consistently?
    By amazingm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-15-2006, 10:30 AM
  7. Replies: 0
    Last Post: 10-18-2005, 02:05 PM

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