Excel: Determining the Name of the Active MacroLast reviewed: November 29, 1994Article ID: Q63954 |
The information in this article applies to:
SUMMARYIf 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 INFORMATIONThe 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 macroThe 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
|
KBCategory: kbusage
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |