Microsoft Office Tutorials and References
In Depth Information
Figure 14-5. The activate sheet dialog
In particular, when the user selects ActivateSheet , we would like to present her with a custom
dialog that lists all of the sheets in the active workbook, as shown in Figure 14-5 . The user can
select one of these sheets, which will then be activated.
Figure 14-5. The activate sheet dialog
To implement this utility, we need to do the following:
Change the ActivateSheet procedure in basMain to open the Activate Sheet dialog
(instead of displaying the current message).
Design the Activate Sheet dialog itself.
Write the code behind the Activate Sheet dialog.
14.6.1 Back to SRXUtils
So crank up the SRXUtils.xls worksheet and replace the ActivateSheet procedure in basMain :
Public Sub ActivateSheet()
MsgBox "This is the ActivateSheet utility"
End Sub
with the procedure:
Public Sub ActivateSheet()
dlgActivateSheet.Show
End Sub
which simply displays the Activate Sheet dialog (which we will call dlgActivateSheet ).
14.6.2 Create the UserForm
After you insert a UserForm into your project, you should use the Properties window to change its
Name property to dlgActivateSheet and its Caption property to "Activate Sheet." Then you
can add the controls to the form. The UserForm in Figure 14-5 has two command buttons and one
list box.
14.6.2.1 List box
Place a List box on the form as in Figure 14-5 . Using the Properties window, set the properties
shown in Table 14-1 . Note that the TabIndex property determines not only the order that 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.
Table 14-1. Nondefault Prope rties of the ListBox Control
Property
Value
Name
lstSheets
 
 
Search JabSto ::




Custom Search