Microsoft Office Tutorials and References
In Depth Information
Table 18-5. Nondefault Properties of the Print Button
Table 18-5. Nondefault Propert ies of the Print Button
Property
Value
Name
cmdPrint
Accelerator
P
Caption
Print
TabIndex
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 Prop erties of the Cancel Button
Property
Value
Name
cmdCancel
Accelerator
C
Caption
Cancel
TabIndex
2
Cancel
True
18.4.2 Create the Code Behind the UserForm
Now it is time to create the code behind these controls.
18.4.2.1 The Declarations section
The Declarations section of the dlgPrintSheets UserForm should contain declarations of the
module-level variables, as shown in Example 18-1 .
Example 18-1. Module-Level Variable Declarations
Option Explicit
Dim cSheets As Integer
Dim sSheetNames() As String
18.4.2.2 Cancel button code
The Cancel button code is shown in Example 18-2 .
Example 18-2. The cmdCancel_Click Event Handler
Private Sub cmdCancel_Click()
Unload Me
End Sub
18.4.2.3 Print button code
The Print button calls the main print procedure and then unloads the form; its source code is
shown in Example 18-3 .
Example 18-3. The cmdPrint_Click Event Handler
 
 
 
 
 
Search JabSto ::




Custom Search