OnKey Method Ignored When a Dialog Box Is Being Displayed (153316)



The information in this article applies to:

  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95
  • Microsoft Excel for Windows 5.0
  • Microsoft Excel 98 Macintosh Edition

This article was previously published under Q153316

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. The OnKey method does not work, however, when a dialog box is being displayed. Dialog boxes, such as message boxes, custom dialog sheets, userforms, and menus cause the OnKey method to ignore the key combination(s) that were set to run the macro.

MORE INFORMATION

This behavior is by design. Dialog boxes are application modal and, therefore, have the application's focus, rendering macros inactive while the dialog boxes are visible.

REFERENCES

Excel 97 or Excel 98 Macintosh Edition

For more information about the OnKey method, from the Visual Basic Editor, click the Office Assistant, type OnKey method, click Search, and then click to view "OnKey Method."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:

176476 OFF: Office Assistant Not Answering Visual Basic Questions


Modification Type:MinorLast Reviewed:8/17/2005
Keywords:kbdtacode kbprb kbProgramming KB153316