OnWindow Property

Applies To

Application Object, Window Object.

Description

Returns or sets the name of the procedure that runs whenever you switch to a window. Read-write.

Remarks

The procedure specified by this property does not run when other procedures switch to the window or when a command to switch to a window is received through a DDE channel. Instead, the procedure responds to a user's actions, such as clicking a window with the mouse, choosing the Go To command from the Edit menu, and so on.

If a worksheet or macro sheet has an Auto_Activate or Auto_Deactivate macro defined for it, those macros will be run after the procedure specified by OnWindow.

Example

This example runs my_Stock_Procedure when the user switches to the STOCKS.XLS window from another workbook window.


Application.Windows("STOCKS.XLS").OnWindow = "my_Stock_Procedure"

This example disables the OnWindow procedure for the STOCKS.XLS window.


Application.Windows("STOCKS.XLS").OnWindow = ""