A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Steps for creating the userform:
- In the VBE choose Insert, UserForm
2. In the Properties window on the lower left (if you don't see it choose View, Properties Window) change the Caption property to a name you want to display at the top of the dialog box = userform, optionally, change the Name property to something like frmPrint (no spaces in the name property)
- Click on the userform in the right hand area and the toolbox should be visible.
- Click the Button tool and then click on the user form where you want one of the buttons.
5. With the button selected, change its Name property to btnPrint, change its Caption property to Print.
- Repeat step 5 for a Print Preview button and a Cancel button
- Double-click the Print button and add the code the following code to the form's module
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdPreview_Click()
Unload Me
Selection.PrintPreview
End Sub
Private Sub cmdPrint_Click()
Selection.PrintOut
Unload Me
End Sub
You will add one line in your regular module to launch the dialog box:
frmPrint.Show
If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Cheers, Shane Devenshire