ON.WINDOW macro

Runs a specified macro when you switch to a particular window.

Syntax

ON.WINDOW(window_text, macro_text)

Window_text    is the name of a window in the form of text. If window_text is omitted, ON.WINDOW starts the macro whenever you switch to any window, except for windows that are named in other ON.WINDOW statements.

Macro_text    is the name of, or an R1C1-style reference to, a macro to run when you switch to window_text. If macro_text is omitted, switching to window_text no longer runs the previously specified macro.

Remarks

 

Examples

In Microsoft Excel for Windows, the following macro formula runs the macro beginning at cell R1C2 when you switch to the window MAIN.XLS:

ON.WINDOW("MAIN.XLS", "R1C2")

The following macro formula stops the macro from running when you switch to MAIN.XLS:

ON.WINDOW("MAIN.XLS")

In Microsoft Excel for the Macintosh, the following macro formula runs the macro named ShowAlert when you switch to the window MAIN WINDOW:

ON.WINDOW("MAIN WINDOW", "ShowAlert")

The following macro formula stops the macro from running when you switch to MAIN WINDOW:

ON.WINDOW("MAIN WINDOW")

Related Functions

GET.WINDOW   Returns information about a window

ON.KEY   Runs a macro when a specified key is pressed

ON.SHEET   Triggers a macro whenever the specified sheet is activated from another sheet

WINDOWS   Returns the names of all open windows

Return to index