Microsoft KB Archive/213792

= XL2000: OnKey Method Is Ignored When a Dialog Box Is Displayed =

Article ID: 213792

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q213792





SYMPTOMS
In Microsoft Visual Basic for Applications, you can use the OnKey method to run a particular macro when a key or key combination is pressed. However, the OnKey method does not work as expected when a dialog box is displayed.



CAUSE
This behavior can occur because dialog boxes -- such as message boxes, custom dialog sheets, UserForms, and menus -- cause the OnKey method to ignore the key combinations that are set to run the macro. In other words, dialog boxes are application modal and, therefore, have the application's focus, rendering macros inactive while the dialog boxes are visible.

