View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Prevent users from running macros

But if they can find the name of the procedure, they can type the name of the
sub in the run dialog.

They can't select it and run it, but they can type and run.



George Nicholson wrote:

In addition to the other answers you've been given, procedures with
arguments and functions that return values can't be run from the Macro list,
so Excel ignores them when creating the list. Therefore, simple workarounds
can also include minor code modifications like the following, which should
have no impact on how your existing code runs, and doesn't require changes
to existing module/procedure scoping.

Public Sub MySub(Optional DummyArg as Boolean)
'the argument (even when optional and never supplied) will prevent this
from appearing in the macro list.
End Sub

or

Public Function MySub()as Boolean
'the return value (which you don't have to actually use) will prevent
this from appearing in the macro list.
End Function

--

HTH,

George Nicholson

Remove 'Junk' from return address.

"Alan Hutchins" wrote in message
...
Hi,

I have a workbook, where the VBA code is password
protected.

The macros within the workbook are operated by buttons -
so I'm happy with that.

However, what I really want to be able to do, is to stop
users from selecting Tools, Macro, and then running a
macro from there (NOTE - I do not want to hide this option
from the Toolbar). Is there any way of preventing users
from running a macro in this way ?

Note - Also, I do not want to protect the workbook either.


--

Dave Peterson