ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Hidden Macro (https://www.excelbanter.com/excel-discussion-misc-queries/128682-hidden-macro.html)

Shu of AZ

Hidden Macro
 
Is it possible to hide a macro so no one can see what code exists? If so how
do you do it?

JMB

Hidden Macro
 
You could write it down and hide it under your mattress <g

Maybe you could try putting a password on the VBA project. Right click on
your project, select properties - input a password.

Also, if you put in a dummy parameter, it should not show up in the macros
dialog box - so the user should not be able to access it through the excel
menus.

Sub Test (dummy as string)

End Sub


However, there are programs that can break the VBA project passwords - so
you are unlikely to stop someone intent on getting at it.


"Shu of AZ" wrote:

Is it possible to hide a macro so no one can see what code exists? If so how
do you do it?


JLatham

Hidden Macro
 
It's pretty hard to hide code. To keep macro names from showing up in the
Macro list, use Private Sub vs plain Sub declarations. This leaves you with
the problem of how to access them.

You can set up a button on the sheet and attach it to a macro (with plain
Sub declaration initially) and then change the macro to a Private Sub. That
will allow you to run it from the control but not from the Tools | Macro |
Macros list.

Another way to hide one is to make it a function instead of a sub. Again,
the question is how do you make it run when you want to. One way would be to
use some worksheet event handler to trigger it, like having a one-liner in a
worksheet's _BeforeDoubleclick event to call the function: you double-click
on the sheet, your hidden macro runs as a Function.

But to keep people from viewing the code, without resorting to creating
add-ins or putting the code in a separate workbook and having to have both
open to perform your operations, what JMB is about it: protect the VBA
Project with a password and choose the 'Prevent Viewing' option so that
people can't see or change the code without the password ... and hope they
don't have a password cracker handy.

People are immediately going to get clued in to the fact that there are Subs
or Functions in a workbook if their Macro Security is set to Medium or High
when they open the workbook. That is enough to get the curious started in a
search...

"Shu of AZ" wrote:

Is it possible to hide a macro so no one can see what code exists? If so how
do you do it?



All times are GMT +1. The time now is 12:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com