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 cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Print preview

Status
Not open for further replies.

peteeng

Chemical
Joined
Apr 30, 2003
Messages
4
Location
CA
I have written the following VB code(simplified) for printing output summary of a program that I have written, what I like to do is to be able to preview the output before it actually prints to the printer. Can anybody help me out??? Thanks you

Private Sub CmdPrint_Click()

Cust = txtName.Text
CustRef = txtCustRef.Text
Proj = txtProj.Text
Engr = txtEngr.Text
Offer = txtOffer.Text
Job = txtJob.Text
sFileName = txtFile.Text

Printer.ScaleMode = 5
dXOffSet = (Printer.Width / 1444 - Printer.ScaleWidth) / 2
dYOffSet = 5 / 16
Printer.CurrentX = 1 - dXOffSet
Printer.CurrentY = 1 - dYOffSet
Printer.DrawWidth = 10
Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
Printer.Line -(Printer.CurrentX, Printer.CurrentY + 9.5)
Printer.CurrentX = 1 - dXOffSet
Printer.CurrentY = 1 - dYOffSet
Printer.Line -(Printer.CurrentX, Printer.CurrentY + 9.5)
Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
Printer.CurrentX = 1 - dXOffSet
Printer.CurrentY = 1.725 - dYOffSet
Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
Printer.CurrentX = 1 - dXOffSet
Printer.CurrentY = 1.75 - dYOffSet
Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)

Printer.CurrentX = 6 - dXOffSet
Printer.CurrentY = 1.75 - dYOffSet
Printer.Line -(Printer.CurrentX, Printer.CurrentY + 1)

Printer.CurrentY = 0.75 - dYOffSet
Printer.FontName = "Times New Roman"
Printer.FontSize = 18
Printer.Print Tab(25); "DESIGN & SIZING INFORMATION"
Printer.FontSize = 12
Printer.Print Tab(50); "WITH ALL THE TRIMMINGS"
Printer.FontSize = 9
Printer.Print Tab(72); "By: Authors"
Printer.FontSize = 10
Printer.CurrentX = 1.1 - dXOffSet
Printer.CurrentY = 1.8 - dYOffSet
Printer.Print "CLIENT :"; Tab(35); Cust; Tab(105); "DESIGNED BY :"; Tab(125); Engr
Printer.DrawWidth = 1
Printer.CurrentX = 1 - dXOffSet
Printer.CurrentY = 2 - dYOffSet
Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
Printer.CurrentX = 1.1 - dXOffSet
Printer.CurrentY = 2.05 - dYOffSet
Printer.Print "REFERENCE :"; Tab(35); CustRef; Tab(105); "OFFER NO. :"; Tab(125); Offer
Printer.CurrentX = 1 - dXOffSet
Printer.CurrentY = 2.25 - dYOffSet
Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
Printer.CurrentX = 1.1 - dXOffSet
Printer.CurrentY = 2.3 - dYOffSet
Printer.Print "PROJECT :"; Tab(35); Proj; Tab(105); "JOB NO. :"; Tab(125); Job
Printer.CurrentX = 1 - dXOffSet
Printer.CurrentY = 2.5 - dYOffSet
Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
Printer.CurrentX = 1.1 - dXOffSet
Printer.CurrentY = 2.55 - dYOffSet
' Printer.Print Tab(105); "FILE NO. :"; Tab(125); File
Printer.Print "DESIGN BY :"; Tab(35); Engr; Tab(105); "FILE NO. :"; Tab(125); sFileName

Printer.CurrentX = 1 - dXOffSet
Printer.CurrentY = 2.75 - dYOffSet
Printer.DrawWidth = 10
Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
Printer.CurrentY = 2.6 - dYOffSet
Printer.FontSize = 11
Printer.FontBold = True
Printer.Print Tab(50); "PROCESS DESIGN CONDITIONS"
Printer.FontBold = False

Printer.EndDoc
End Sub
 
Hi,

In the past I've done with a picture box on a form and then printed to the picture box control.

Picture1.Cls
Picture1.Print "JOB NAME"
Picture1.Line (0, 0)-(30, 0)

You get the idea.

Hope that helps
 
Dim OutputPRN as Object
'change all your statements to use this object instead
' Printer.FontSize = 11
' becomes
' OutputPRN.FontSize = 11
'
'At the begining of your routine, query

Private Sub CmdPrint_Click()
if PrintPreviewFlag Then _
Set OutputPRN = Picture1 _
Else _
Set OutputPRN = PRINTER
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top