Protecting a VBA project

Lynnette

New Member
Joined
Apr 1, 2009
Messages
7
I need to password protect a VBA project. This is being done internally and the people with the password will be within the office. How do I do the protect. The worksheets will be password protected, but in order to perform sum of the operations the worksheets will be unprotected and then reprotected. We are trying to protect the password that will be in the documentation in the macro.
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Colin Legg

MrExcel MVP
Joined
Feb 28, 2008
Messages
3,497
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi,

Open up the visual basic editor (Alt+F11) and make sure you have your project selected in the project explorer window.

Then go Tools | VBAProject Properties | Protection Tab
Tick the lock project for viewing checkbox
Enter in the password.

You'll only see the protection take effect once you have Saved + Closed + Reopened the file.


By the way, do the worksheets need to be unprotected to do this sum?
 

Diablo II

Well-known Member
Joined
Sep 28, 2008
Messages
538
try this

Code:
ActiveSheet.Protect password:="anystring"

Code:
ActiveSheet.Unprotect password:="anystring"
 

Lynnette

New Member
Joined
Apr 1, 2009
Messages
7
Hi,

Open up the visual basic editor (Alt+F11) and make sure you have your project selected in the project explorer window.

Then go Tools | VBAProject Properties | Protection Tab
Tick the lock project for viewing checkbox
Enter in the password.

You'll only see the protection take effect once you have Saved + Closed + Reopened the file.


By the way, do the worksheets need to be unprotected to do this sum?

Yes, they do.
 

Colin Legg

MrExcel MVP
Joined
Feb 28, 2008
Messages
3,497
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
If you say so, Lynette. :)

If you have any more questions or problems regarding protecting the VBA project then let us know.
 

jcalhau

New Member
Joined
Nov 13, 2006
Messages
1
Hi, I need to protect a VBA project programatically (ie with code). Anyone has any helpful sugestions?
The problem is that when I programatically copy the worksheets to a new workbook and save that workbook "as" the saved version's code contained in the worksheets is not protected even thought the original project is, allowing user to interfere with it.
Many thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,123,397
Messages
5,601,434
Members
414,450
Latest member
Cassy_sn

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
Top