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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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,223,444
Messages
6,172,171
Members
452,445
Latest member
walkman99

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