Microsoft KB Archive/50095

From BetaArchive Wiki


Excel: Custom Dialog Box Must Have Default Button

Last reviewed: November 2, 1994
Article ID: Q50095

SUMMARY

When you press the RETURN key (on the main keyboard) in a custom dialog box that has no default buttons but has a nondefault OK or Cancel button, Microsoft Excel versions 2.20 and 3.00 close the dialog box.

In Excel version 1.50, the same dialog box remains open. Excel 2.20 and 3.00 use the Standard Dialog Manager (SDM), which does not support dialog boxes not being dismissed when RETURN or ENTER (on the numeric keypad) is pressed.

The following method achieves the same effect as Excel 1.50:

  1. Add a line to the dialog box definition table with a default OK button. This can be made to have zero height and width to hide the button.

    To do this in the Dialog Editor, create a default OK button. Then copy this dialog into your macro sheet. This should appear similar to the example below:

             A      B       C       D       E       F
           -------------------------------------------
          |     |       |       |       |       |
          |  1  |       |       |  0    |  0    | <-- (Default OK button)
          |  3  |       |       |       |       |  OK
          |  2  |       |       |       |       |  Cancel
          |  5  |       |       |       |       |  Static Text
    
       Note: Make sure that the fourth (height) and fifth (width) columns
       of the dialog box definition table for the default OK button
       contain 0 (zero). This makes the default OK button invisible.
    
  2. Enter your DIALOG.BOX statement, as follows:

           =IF(DIALOG.BOX(dbox)=1,GOTO(ref))

    "dbox" refers to the range of the dialog box definition table. "ref" refers to the cell containing the IF statement. For example, if the IF statement is located in cell A1 of the macro sheet, the GOTO statement should read GOTO(A1).

Note: The dialog box definition table must contain seven columns.


KBCategory: kbother

KBSubcategory:

Additional reference words: 1.50 2.20 3.00


Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.