Change file permissions in VBA

VorLag

Board Regular
Joined
May 13, 2013
Messages
205
I have several files that I don't want anyone to edit or even look at. I create a version for them to edit and keep my version locked. However, I want the macro to remove permissions set while it's creating the other version. I already have a macro that creates their version, but I want to add the part where it removes permissions. Is there a way to do that?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I'm trying this:

Rich (BB code):
Sub RemovePermissions()
    Dim myPermission As Office.Permission
    Set myPermission = ThisWorkbook.Permission
    myPermission.Enabled = False
End Sub

But, it doesn't do anything. I tried to set permissions using a similar method, but that also didn't work. I can't find a way to use the Shell function to do this, do you have a snippet somewhere? I haven't been able to find one that I could even modify.
 
Upvote 0
One more thing - if you want the macro to work on other workbooks, you need to change "ThisWorkbook" to "ActiveWorkbook". Just in case someone else finds this macro useful.
 
Upvote 0

Forum statistics

Threads
1,214,655
Messages
6,120,760
Members
448,991
Latest member
Hanakoro

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