In sort of reverse order ...
> I was hoping that since it is compiled code, the source could be
> blown away after compiling it ...
It's not really compiled code. It's still a source-level interpreter, but
it does store away intermediate partial compilations to use if the source
environment doesn't change. Sounds a bit unclear? That's because I'm a bit
unclear. It always seems to do some sort of source code check -
particularly the first time you run the code after loading the sheet - but
it definitely does store some intermediate information away with the
worksheet. I've never delved more deeply into it.
But the end result is that you can't consider it as compiled code.
> I just want to hide my code from others. It's just a "you
> can have my sheet and use it for free, but you can't see my code" sort
> of thing.
If you want people to use your code, but not see it, then it needs to be
accessible (at the "call" level) to them. This is what a password gives
you.
> However, the discussion about Variant parameters lost me as far as
> whether/when they cause the macro to be seen / not seen in the menu list.
No problem. The discussion did range a bit. IIRC it went a bit like this
...
- Subs with no parameters can be seen.
- Subs with parameters can't be seen, but it's a nuisance to have to use
dummy parameters on the calls.
- What about making them optional, so that they don't need to actually be
provided in the calls? Yes that's fine - optional String or Integer or
other parameters can be omitted in the calls, but the routine is still not
visible.
- But optional Variant parameters do not stop the Sub being hidden. Why the
difference?
- Shouldn't be any difference, because both forms of optional parameters
allow the Sub to be called without parameters, so why aren't both types
visible?
- Here it got technical and obscure, and I for one was speculating, rather
than speaking authoritatively. But optional Variant parameters are
definitely implemented differently inside Excel to optional parameters of
other types. The other types (when omitted) will be given default values;
Variant parameters (when omitted) will be given "missing" status. A subtle
difference, but probably this is triggering the difference.
In summary, an optional String or Integer parameter will cause the Sub not
to be visible, and you don't need to provide that parameter in other calls
to it.