Thread: Calling macro?
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default Calling macro?

On Mar 13, 2:05*pm, "Rick Rothstein"
wrote:
if your AnotherMacro [...] it will only be called from
within other code, then you can give it an argument and
pass the calling routine's name through it.

[....]
Another possibility is to use a global variable to
transmit the name... this method can be used with real
macros as well as subroutines.


Notwithstanding what I explained regarding symbol tables in general, I
do agree with you that it is probably better to use one of these
mechanisms instead of relying on any programming interface that VBA or
the kernel might provide.

In fact, for most purposes, I would not pass a name at all, except for
debugging/logging purposes. Instead, I would pass a number, which the
called procedure might use to alter its behavior.

One benefit of relying on a number (or arbitrary string) instead of
the caller's name is that procedure names have a habit of changing
over time ;-). Moreover, it allows multiple callers to affect the
same conditional behavior, which should be defined in a "functionally
cohesive" manner independent of a caller's name.