Locking Macros

  • Thread starter Thread starter ranswrt
  • Start date Start date
R

ranswrt

I have my worksheet, workbook and VBE all with the protection turned on. Is
there a way to stop a user from going to Tool -> Macro->Macros... and running
a procedure?
 
I have my worksheet, workbook and VBE all with the protection turned on. Is
there a way to stop a user from going to Tool -> Macro->Macros... and running
a procedure?

Put Private in front of Sub and it will only be accessible to other
procedures in that Module.

Private Sub DoStuff()
....
End Sub

You can also put an argument in the sub and it won't show up in the Macro
dialog.

Sub DoStuff(Optional bFake as Boolean)
....
End Sub

You don't have to do anything with bFake, just its presence will prevent it
from showing up.
 
I used 'bfake' and that worked great. Is any other consequences using
'bfake' other then it not putting the macro in the dialog box?
 
I don't think so. Make sure you use the Optional keyword so it doesn't
break any existing macros that call it. Oh, and you won't be able to run it
using F5 in the VBE. You'll have to call it from the Immediate Window, but
that's a small price to pay.
 
Thanks for your help

Dick Kusleika said:
I don't think so. Make sure you use the Optional keyword so it doesn't
break any existing macros that call it. Oh, and you won't be able to run it
using F5 in the VBE. You'll have to call it from the Immediate Window, but
that's a small price to pay.
 

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