Create the UserForm 1
Create the dialog shown in Figure 18-7 in the Print.xls workbook. Name the dialog dlgPrintSheets and set its Caption property to "Print Sheets." Then change the PrintSheets procedure to:
Public Sub PrintSheets()
dlgPrintSheets.Show End Sub
The dlgPrintSheets dialog has two command buttons and one list box:
dlgPrintSheets.Show
18.4.1.1 List box
Place a list box on the form as in Figure 18-7. Using the Properties window, set the properties shown in Table 18-4.
|
Property |
Value |
|
Name |
lstSheets |
|
TabIndex |
0 |
|
MultiSelect |
When the Cancel property of the cmdCancel button is set to True, the button is "clicked" when the user hits the Escape key. Thus, the Escape key will dismiss the print dialog.
The MultiSelect property is set to frmMultiSelectExtended so that the user can use the Control key to select multiple (possibly nonconsecutive) entries and the shift key to select multiple consecutive entries.
The TabIndex property determines not only the order in which the controls are visited as the user hits the Tab key, but also determines which control has the initial focus. Since we want the initial focus to be on the list box, we set its tab index to 0.
18.4.1.2 Print button
Place a command button on the form as in Figure 18-7. Using the Properties window, set the properties shown in Table 18-5.
|
Table 18-5. Nondefault Properties of the Print Button | |
|
Property |
Value |
|
Name |
cmdPrint |
|
Accelerator |
P |
|
Caption |
|
|
Tablndex |
1 |
18.4.1.3 Cancel button
Place another command button on the form as in Figure 18-7. Using the Properties window, set the properties shown in Table 18-6.
|
Table 18-6. Nondefault Properties of the Cancel Button | |
|
Property |
Value |
|
Name |
cmdCancel |
|
Accelerator |
C |
|
Caption |
Cancel |
|
Tablndex |
2 |
|
Cancel |
True |
Post a comment