Difficult "read-only" question

mae0429

Board Regular
Joined
Jun 12, 2008
Messages
114
Hi,

I'm trying to come up with a way to save an updated version of a read-only file. That is to say, there is a read-only protected file on a server that needs to be updated once a month. Is there a way that certain owners (myself) can automate the whole "uncheck read-only, save updated file over old file, then recheck read-only" process?

To put it in context, I have code that takes a master file and splits certain sheets up into separate books. I need to save those newly-created books as files that currently exist in read-only form.

Thanks, and good luck!
-Matt
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
It's probably easier for you (or your IT department) to set the permissions of the *folder* (instead of the file) accordingly.

Just give you and whoever else write access to the folder and everyone else read only access.
 
Upvote 0
Welcome to the Board!

I did some messing around with that kind of thing a few years ago. Here's an example of how you can change the status:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> SetAsReadOnly()<br>    <SPAN style="color:#007F00">'   Test for PC User Name</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> strUser <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>        strUser = Environ("USERNAME")<br>        <SPAN style="color:#007F00">'   MsgBox strUser</SPAN><br>        <br>     <SPAN style="color:#007F00">'  Set Read only File Access for each Office's specific version</SPAN><br>    <SPAN style="color:#00007F">Select</SPAN> <SPAN style="color:#00007F">Case</SPAN> strUser<br>        <SPAN style="color:#007F00">'   Full Workbook Access</SPAN><br>        <SPAN style="color:#00007F">Case</SPAN> <SPAN style="color:#00007F">Is</SPAN> = "YourUserName", "AnotherUser"<br>            <SPAN style="color:#00007F">If</SPAN> ActiveWorkbook.ReadOnly Then _<br>                ActiveWorkbook.ChangeFileAccess Mode:=xlReadWrite, WritePassword:="admin"<br>        <SPAN style="color:#007F00">'   Limit Access</SPAN><br>        <SPAN style="color:#00007F">Case</SPAN> <SPAN style="color:#00007F">Is</SPAN> <> "YourUserName"<br>            <SPAN style="color:#00007F">If</SPAN> <SPAN style="color:#00007F">Not</SPAN> ActiveWorkbook.ReadOnly Then _<br>                ActiveWorkbook.ChangeFileAccess Mode:=xlReadOnly, WritePassword:="admin"<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Select</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,

(Sup Matt!)
 
Upvote 0
Yeah, that would do it. Way to take the VBA fun out of it...;)

Just kidding, thank you for the help!
 
Upvote 0
Smitty,

That's pretty neat...I'll play around with that on the side and see where it takes me. It'd be useful to have for other situations.

Thanks a million!
 
Upvote 0

Forum statistics

Threads
1,214,407
Messages
6,119,332
Members
448,888
Latest member
Arle8907

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