Excel: Determining the Name of the Active Macro
ID: Q63954
|
The information in this article applies to:
-
Microsoft Excel for the Macintosh, versions 2.2, 3.0, 4.0
SUMMARY
If a macro is renamed by the person using it, this can cause problems
with such macro statements as ACTIVATE and SAVE.
Although you can use GET.DOCUMENT(1) to return the name of the active
document, this method is useful only if the macro sheet is already the
active document. If the macro sheet is hidden or if it is not the only
document open, there is no guarantee that GET.DOCUMENT(1) will return
the macro name.
However, you can use FORMULA.GOTO to activate the macro sheet without
knowing the macro sheet's name.
MORE INFORMATION
The following macro is defined as auto_open and therefore will run
every time the macro sheet is opened:
A1: auto_open
A2: =ACTIVATE(WINDOWS()) ;In case all windows are hidden
A3: =FORMULA.GOTO(A1) ;Goes to A1 on running macro sheet
A4: =GET.DOCUMENT(1) ;Name of active sheet (this one)
A5: =RETURN() ;end macro
The value in cell A4 contains the name of the macro sheet after this
macro is run. Because this name is text, it can be used in any
subsequent function requiring the macro name. For example:
=ACTIVATE(A4)
The above function will activate the macro whose name was returned by
cell A4.
REFERENCES
"Microsoft Excel Function Reference," version 4.0, pages 172-173
"Microsoft Excel Function Reference," version 3.0, page 93
"Microsoft Excel Functions and Macros," for the Macintosh, version
2.2, page 227
Additional query words:
macrosheet function command
Keywords :
Version :
Platform :
Issue type :
Last Reviewed: March 21, 1999