troubleshooting Question

Set PaperSize using info from CommonDialog control

Avatar of MTecho
MTecho asked on
Visual Basic Classic
22 Comments1 Solution3878 ViewsLast Modified:
Usually it is possible for the program user to set the size of paper for printed output, using the ShowPrinter method of the common dialog control. Unfortunately the common dialog control does not have a 'PaperSize' property.

Is it possible to get the paper size from the CommonDialog control, so it can be used to set Printer.PaperSize?

I.e. How would I replace 'Printer.PaperSize = vbPRPSA4
' in the following code with something that will get the paper size from the common dialog control?


Private Sub Print()
    On Error GoTo PrintError
    '
    CommonDialog.CancelError = True
    CommonDialog.Flags = cdlPDHidePrintToFile + cdlPDSelection
    CommonDialog.ShowPrinter
    Printer.Orientation = CommonDialog.Orientation
    Printer.PaperSize = vbPRPSA4
    '
    '   Print statements
    '
    Printer.EndDoc
    Exit Sub
    '
PrintError:
    Select Case Err.Number
    Case 32755
        'MsgBox "Print cancelled."
    End Select
    Exit Sub
End Sub
ASKER CERTIFIED SOLUTION
Electrosonics

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 22 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 22 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros