Microsoft Office Tutorials and References
In Depth Information
Table 21-11. Nondefault Properties of the Cancel Button
Place another command button on the form as in Figure 21-32 . Using the Properties window, set
the properties shown in Table 21-11 .
Table 21-11. Nondefault Pro perties of the Cancel Button
Property
Value
Name
cmdCancel
Accelerator
C
Caption
Cancel
TabIndex
2
Cancel
True
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.
21.18.2 Create the Code Behind the UserForm
Now it is time to create the code behind these controls.
21.18.2.1 The Declarations section
The Declarations section of the UserForm should contain declarations of the module-level
variables, as shown in Example 21-5 .
Example 21-5. Module-Level Declarations in the UserForm's Declarations Section
Option Explicit
Dim cCharts As Integer
Dim sChartObjNames() As String
Dim sSheets() As String
21.18.2.2 Cancel button code
The Cancel button code is shown in Example 21-6 .
Example 21-6. The Cancel Button's Click Event Handler
Private Sub cmdCancel_Click()
Unload Me
End Sub
21.18.2.3 Print button code
The Print button calls the main print procedure and then unloads the form, as shown in Example
21-7 .
Example 21-7. The cmdPrint_Click Procedure
Private Sub cmdPrint_Click()
PrintSelectedCharts
Unload Me
End Sub
21.18.2.4 The Form's Initialize event
 
 
 
 
Search JabSto ::




Custom Search