Microsoft KB Archive/71298

{| = Excel: Setting the Focus in a Custom Dialog Box =
 * width="100%"|

Last reviewed: November 3, 1994

Article ID: Q71298 The information in this article applies to:
 * Microsoft Excel for Windows, versions 2.x, 3.0, 4.0
 * Microsoft Excel for OS/2, versions 2.2, 2.21, 3.0

SUMMARY
By default, the focus of a dialog box will be the first item listed in the dialog box description unless a default OK or default Cancel button is used. The default button will then have the focus instead of the first item listed. However, it is possible to override or change these defaults and specify which item you prefer to have as the focus when the dialog box is displayed.

Note that in Microsoft Excel version 5.0, you can control the focus in a dialog box by using the Tab Order dialog box in the dialog sheet. For more information about the tab order in a dialog box in Microsoft Excel version 5.0, query on the following words in the Microsoft Knowledge Base:

tab and order and defaultbutton

MORE INFORMATION
The focus can be set to another item by placing a number in the Init/Result column of the first row of the dialog definition. This number should correspond to the position of the preferred item in the dialog definition. Items are numbered starting with 1 and beginning with the second row of the dialog box definition table. For example, placing a number 2 in the Init/Result column of the first line will cause the item located in the third row of the dialog definition to be selected when the dialog box is displayed.

You will not be able to set the focus to items that are not editable, or can be chosen such as buttons or check boxes.

The dialog definition always contains one or more rows and seven columns. The Init/Result column is always the seventh column in the dialog definition.