XL: OnKey Method Ignored When a Dialog Box Is Being Displayed

Last reviewed: February 3, 1998
Article ID: Q153316
The information in this article applies to:
  • Microsoft Excel 98 Macintosh Edition
  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a

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.

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q133136
   TITLE     : Using the OnKey Method in a Visual Basic Macro

REFERENCES

For more information about the OnKey method in Visual Basic for Applications, click Search in Visual Basic Reference Help and type:

   OnKey


Additional query words: 5.00 5.00a 5.00c 7.00 7.00a XL97 8.00 XL98 XL7 XL5
Keywords : kbcode kbprg PgmOthr
Version : WINDOWS:5.0,5.0c,7.0,7.0a,97; MACINTOSH:5.0,98
Platform : MACINTOSH WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.