How to protect a code with password to avoid mishandling

  • Thread starter Thread starter bobby
  • Start date Start date
B

bobby

Hi,

I have wriyyen a VBAcode in Excel Now i want the the code to be
protected nor to be seen by others to avoid mishandling, as my
worksheet is a shred one. help me how to protect the code.

Regards

Bobby.
 
Goto to the VB editor (Alt-F11), then in the "Project Explorer" Window (if
it is not visible then choose View->Project Explorer from the main menu)
click on the VBA Project heading for the workbook code you wish to protect
and right click, choose VBA Project Properties. In the project properties
dialog choose protection and set the password etc.

Next time you open the workbook you cannot view the code without the
password.

NOTE: This is not a totally secure method but will stop most tampering.
 
If you declare your sub as Private then they will not be visible in the
Run-Macro menu e.g.

Private Sub Macro1()

Also if you pass parameters then they will not be visible e.g.

Sub Macro2(par1)

This is also true for public subs e.g.

Public Sub Macro3(par1)

Take a look at the VB help for the Sub Statement for limitations of the
scope of these different types of Subs.

If also worth noting that Functions are also not visible in the Run-Macro
menu.
 
You can also add

Option Private Module

at the start of a module, to prevent the macros contained within it being
displayed in the "Run" list.

regards

Pete





Nigel said:
If you declare your sub as Private then they will not be visible in the
Run-Macro menu e.g.

Private Sub Macro1()

Also if you pass parameters then they will not be visible e.g.

Sub Macro2(par1)

This is also true for public subs e.g.

Public Sub Macro3(par1)

Take a look at the VB help for the Sub Statement for limitations of the
scope of these different types of Subs.

If also worth noting that Functions are also not visible in the Run-Macro
menu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top