XL2000: OnKey Method Is Ignored When a Dialog Box Is Displayed (213792)



The information in this article applies to:

  • Microsoft Excel 2000

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.

REFERENCES

For more information about the OnKey method, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type onkey method in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbdtacode kbprb kbProgramming KB213792