Lock access to the VBA project via VBA

Engineer Joe

Well-known Member
Joined
Jun 10, 2005
Messages
549
Either my google-foo skillz are waning or google itself just isn't useful in finding the distinction in my inquiry, so here I am. Long time, no see Mr. Excel. Let me preface my question with this. When you go into in the VBA project for an Excel file and click on the Tools Dropdown and select "VBAProject - Properties," you get a pop-up window and then select the "Protection" tab, you can lock the project with a password. I need to do this via VBA. So that's my question. How do I accomplish this via VBA. I need to do this via VBA because I've got a ton of worksheet-specific XLSM files. I got some code several years ago that I employ regularly that lets me open a bunch of files in a subfolder and execute whatever macro I want on those files. So, basically, I want to run this on my entire file folder structure for all XLSM files. So the code I need is firstly the code to lock all the files...then I need another bit of code to unlock the files automatically that I would conceivably insert into my personal addin that just unlocks the files when I open them. Can anyone help me figure that out? Yes, a little bit inception-esque here, so I figure it'll be kind of fun for whoever knows how to do it. Alrighty, I'm eagerly awaiting a reply from a true Excel master whom I'll worship endlessly and create a little shrine to if you can help me out here.

THANKS!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
This might pooint you in the right direction, but it uses SendKeys, which are very unreliable.
 
Upvote 0
In VBA window click Tools. Then click VBA Project Properties. Click the Protection Tab. Lock for viewing and enter Password.
 
Upvote 0
In VBA window click Tools. Then click VBA Project Properties. Click the Protection Tab. Lock for viewing and enter Password.
I should've read the entire post. :) Disregard my answer.
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,520
Members
449,088
Latest member
RandomExceller01

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