Print (multi page) UserForm

adambc

Active Member
Joined
Jan 13, 2020
Messages
373
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I don’t like it, but User pressure has prevailed!!!

Having built a 3 page* UserForm to emulate a 3 section paper form (with all the controls etc to ensure data completeness/accuracy/etc!), as a result of User pressure, I need to print a 3 page version of my UserForm (including data values) ...

* there is no scrolling on any of the pages themselves, but there is scrolling in a few of the Text Boxes

I can find solutions to printing a single page UserForm, but does anyone have any ideas how to print multiple pages as a single “document”?

Thanks ...
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Check if the following is what you need.
What the macro does is select page1 of the multipage, copy the screen and paste it on an excel sheet, advance to page2, copy and paste, advance page3 copy and paste, at the end print the sheet.

VBA Code:
Private Sub CommandButton1_Click()
  Dim i As Long, n As Long
  Dim sh As Worksheet
  
  Set sh = Sheets.Add(after:=Sheets(Sheets.Count))
  n = 1
  For i = 0 To 2
    MultiPage1.Value = i
    Application.Wait Now + TimeValue("00:00:03")
    DoEvents
    Application.SendKeys "(%{1068})"
    DoEvents
    sh.Paste
    Selection.Top = n
    n = n + Me.Height + 5
  Next
  With sh.PageSetup
    .CenterHorizontally = False
    .CenterVertically = False
    .Orientation = xlPortrait
    .Draft = False
    .PaperSize = xlPaperLetter
    .FirstPageNumber = xlAutomatic
    .Order = xlDownThenOver
    .BlackAndWhite = False
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = 1
  End With
  sh.PrintOut Copies:=1, Collate:=True
  Application.DisplayAlerts = False
  sh.Delete
End Sub
 
Upvote 0
This looks great, but I only work one day a week so it will be next week before I can try it ...

Can follow how it works, but not sure what ... Application.Wait Now + TimeValue("00:00:03") ... does?

Also what the 2 DoEvents do?

Many thanks ...
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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