Need VBA code to print specific pages or all pages in a MultiPage UserForm

pimp_mentality

New Member
Joined
Oct 15, 2015
Messages
46
Good day all,

As the topic suggested I would like a line of code which will allow me to print a specific page from a multipage UserForm or print the entire form (all pages) when click commandbutton I created

Assistance in this regard would be greatly appreciated.

I would also like a line of code which will clear all textboxes when I click the commandbutton I created.

Thanks
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I am currently unable to post a sample worksheet as I know that would help however if you advise me re what additional info you require to assist me with this issue I will provide it.
 
Upvote 0
There is only one print method for a userform, PrintForm.
Code:
Me.PrintForm
It will print the userform, normally badly, in it's current state ie only the currently active page of the multipage will be printed.
 
Upvote 0
Yes. I was told of this code i.e. .PrintForm but it would only print the first page. i was hoping that their was a way to print all pages of just specific pages but i guess not.
 
Upvote 0
Finally could see this in a non-Printable view

Try:
Code:
Option Explicit

Private Sub cmdPrintAllMultiFormPages_Click()
    'Modify to match your form & controls' names
    'Add a command button to the form named 'PrintAllFormPages'
    Dim lPageIndex As Long
    For lPageIndex = 0 To Me.MultiPage1.Pages.Count - 1
        Me.MultiPage1.Value = lPageIndex
        Me.PrintForm
    Next
End Sub

Private Sub cmdClearTextBoxes_Click()
    'Assumes your textbox controls all start with 'txt'
    'Modify to match your form & controls' names
    'Add a command button to the form named 'PrintAllFormPages'
    Dim ct As Control
    For Each ct In UserForm1.Controls
        If Left(ct.Name, 3) = "txt" Then
            ct.Object = ""
        End If
    Next
End Sub
 
Upvote 0
Correction:

Code:
Option Explicit

Private Sub cmdPrintAllMultiFormPages_Click()
    'Modify to match your form & controls' names
    'Add a command button to the form named 'PrintAllFormPages'
    Dim lPageIndex As Long
    For lPageIndex = 0 To Me.MultiPage1.Pages.Count - 1
        Me.MultiPage1.Value = lPageIndex
        Me.PrintForm
    Next
End Sub

Private Sub cmdClearTextBoxes_Click()
    'Assumes your textbox controls all start with 'txt'
    'Modify to match your form & controls' names
    'Add a command button to the form named 'cmdClearTextBoxes'
    Dim ct As Control
    For Each ct In UserForm1.Controls
        If Left(ct.Name, 3) = "txt" Then
            ct.Object = ""
        End If
    Next
End Sub
 
Upvote 0
A button that sent this:
Me.PrintForm
would print the current visible page.

The line:
Me.MultiPage1.Value = lPageIndex
determines which page is visible. 0 for the first page, 1 for the second page, .....
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,591
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top