Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Button on form not working!

Status
Not open for further replies.

rene316

Programmer
Jan 14, 2002
81
0
0
US
Hello,
I have a form I am designing and have a print button, that I need to open the print dialoge box, but it is not working, I am using VB6. Can someone help a poor boy out. I am new, so I am probably, if not definately forgetting something.

Thanks
 
I'm not sure what you are trying, but this works for me. Remember to include a CommonDialog object on your form.


Private Sub cmdPrint_Click()
Dim BeginPage, EndPage, NumCopies, i, x

' Set Cancel to True
CommonDialog1.CancelError = True

CommonDialog1.Orientation = cdlLandscape
On Error GoTo ErrHandler

' Display the Print dialog box
CommonDialog1.ShowPrinter

' Get user-selected values from the dialog box
BeginPage = CommonDialog1.FromPage
EndPage = CommonDialog1.ToPage
NumCopies = CommonDialog1.Copies
For i = 1 To NumCopies
Printer.FontSize = 10
If CommonDialog1.Orientation = cdlPortrait Then
Printer.Orientation = vbPRORPortrait
Else
Printer.Orientation = vbPRORLandscape
End If
Printer.Print Now
Printer.Print
Printer.Print

Printer.EndDoc

Next i
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top