Solved Password creation and applying

June 27, 2013 at 02:36:58
Specs: Windows 7
I have taken a VBA from the forum created by DerbyDad03, manipulated it a little bit and I end up with a password

I have the following two lines of instruction in a number of VBA Subs

' unprotect sheet
Sheets("?????").Unprotect Password:="??????"

' protect sheet
Sheets("?????").Protect Password:="??????", DrawingObjects:=True, Contents:=True, Scenarios:=True

The Sheets title will be entered accordingly, but I need an instruction to place a given password in all the instruction as above. Am I right to think I need a public function for this and if so, could someone please explain and write it for me

See More: Password creation and applying

Report •

June 27, 2013 at 04:07:32
I'm not sure what you are asking for.

If you are entering the sheet names, why can't you just enter the passwords?

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

June 27, 2013 at 04:20:26
The sheet names will not change, however if the password were to be found, I would like the option of changing the password without going through every Sub routine.

The password would be the same for all worksheets

Hence be able to go to a single routine where the password can be changed and affect all other Sub routines

Report •

June 27, 2013 at 06:37:58
✔ Best Answer
Well, the first thing I would do is is set the VBAProject properties for your workbook to "Lock project for viewing" and assign a password to the VBAProject itself so that the hardcoded passwords can not be seen by the casual user.

In the VBE, right click the VBAProject (Workbook Name) and choose VBAProject Properties. Then click the Protection tab and fill in the requested information.

If the Password for the VBAProject is not stored anyplace where the casual user can find it, they won't be able to see the hardcoded password in your actual macro.

That said, I have never tried to modify VBA code via VBA code, but a Google search led me here, which appears to be along the lines of what you are trying to do:

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

Related Solutions

Ask Question