saving a Read-only file

LFKim2018

Active Member
Joined
Mar 24, 2018
Messages
267
I have a Read-only file and I want to un-Read it so that I can make changes and save them then revert it to Read-only.
I have tried the ff codes - but none of them worked..
many thanks

Code:
 ThisWorkbook.ChangeFileAccess xlReadWrite
SetAttr ActiveWorkbook, vbReadOnly
ActiveWorkbook.ChangeFileAccess Mode:=xlReadOnly
ThisWorkbook.ChangeFileAccess xlReadOnly
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
.
My understanding is that a ReadOnly file can have changes made to it, but you will need to save it as a different name. Is that the problem ?

Or do you mean, the workbook is protected and you are unable to unprotect it ?
 
Upvote 0
.
My understanding is that a ReadOnly file can have changes made to it, but you will need to save it as a different name. Is that the problem ?

Or do you mean, the workbook is protected and you are unable to unprotect it ?

Mr. Logit
Thank you for your reply.
I intentionally make the file Read-only so that users can not overwrite it for it is the template.
I want to circumvent that attrib whenever I am making 'housekeeping' of the file only.
Rather than un-read it then making it read-only manually, I want it to be by vba (if that's doable).
I need the codes that is functional - in my OP - I indicated the codes that I used but to no avail.
many many thanks
 
Last edited:
Upvote 0
.
Your posted code does not work here.

This macro does work here :

Code:
Option Explicit


Sub makereadonly()


    ActiveWorkbook.ChangeFileAccess Mode:=xlReadOnly


End Sub

The macro does not prevent changes to the workbook and it does not request saving as a new name.


Are you certain you are not referring to a PROTECTED WORKBOOK ?
 
Upvote 0
.
Your posted code does not work here.

This macro does work here :

Code:
Option Explicit


Sub makereadonly()


    ActiveWorkbook.ChangeFileAccess Mode:=xlReadOnly


End Sub

The macro does not prevent changes to the workbook and it does not request saving as a new name.


Are you certain you are not referring to a PROTECTED WORKBOOK ?


Mr. Logit
I tried your suggestion but when I look at the file attrib - the Read-only check box is not marked.
meaning it is still not Read-only.
My workbook is not protected.
What I intend to do is:
with VBA:
1. un-Readonly the file
2. make file changes/edits (housekeeping)
3. save the file with the same name then
4. revert the file to Read-only.

I need the right codes for steps 1 & 4

many thanks
 
Upvote 0
.
https://smallbusiness.chron.com/excel-prompt-opened-read-write-48685.html

The above resource outlines how to save as READ ONLY and require a password to allow for changes.
However, READ ONLY does not prevent someone from saving the file in another filename with changes that they have made to this new file.

Test it out for yourself.


I would prefer to password protect the file so changes can not be made. You could even prevent the file from being saved unless the password
was implemented.

All depends on your desired level of 'security' .
 
Upvote 0
.
https://smallbusiness.chron.com/excel-prompt-opened-read-write-48685.html

the above resource outlines how to save as read only and require a password to allow for changes.
However, read only does not prevent someone from saving the file in another filename with changes that they have made to this new file.

Test it out for yourself.


I would prefer to password protect the file so changes can not be made. You could even prevent the file from being saved unless the password
was implemented.

All depends on your desired level of 'security' .

thank you..
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top