CSTANG
asked on
Printing
I'm relatively new at V.B 6 and would appreciate any
help I can get!
I'm trying to print text from txt1 to my "Canon BJC-5100" printer.
When the user makes selections in the Font dialog box,
the selected font properties (Color, FontBold, Italic, Underline,
Strikethru, Name, Size) are properly shown on the screen.
But the text are printed out without the selected font properties
except FontSize property.
Can anyone help me to correct my errors?
Private Sub Command1_Click ()
' Set Cancel to True.
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
'Set the Flags property.
CommonDialog1.Flags = cdlCFBoth Or cdlCFEffects
' Display the Font dialog box.
CommonDialog1.ShowFont
' Set text properties according to user's selections.
txt1.Font.Name = CommonDialog1.FontName
txt1.Font.Size = CommonDialog1.FontSize
txt1.Font.Bold = CommonDialog1.FontBold
txt1.Font.Italic = CommonDialog1.FontItalic
txt1.Font.Underline = CommonDialog1.FontUnderlin e
txt1.FontStrikethru = CommonDialog1.FontStriketh ru
txt1.ForeColor = CommonDialog1.Color
Exit SubErrHandler:
' User pressed Cancel button.
Exit Sub
End Sub
Private Sub mnuFilePrint_()
Dim BeginPage, EndPage, NumCopies, Orientation, i
' Set Cancel to True.
CommonDialog1.CancelError = True
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
Orientation = CommonDialog1.Orientation
For i = 1 To NumCopies
' Put code here to send data to your printer.
Printer.ForeColor = txt1.ForeColor
Printer.FontBold = txt1.FontBold
Printer.FontItalic = txt1.FontItalic
Printer.FontUnderline = txt1.FontUnderline
Printer.FontStrikethru = txt1.FontStrikethru
Printer.FontSize = txt1.FontSize
Printer.CurrentX = 1247
Printer.CurrentY = 2438
Printer.Print txt1.Text
I would really appreciate any help that anyone could offer.
Thank you.
CSTANG
help I can get!
I'm trying to print text from txt1 to my "Canon BJC-5100" printer.
When the user makes selections in the Font dialog box,
the selected font properties (Color, FontBold, Italic, Underline,
Strikethru, Name, Size) are properly shown on the screen.
But the text are printed out without the selected font properties
except FontSize property.
Can anyone help me to correct my errors?
Private Sub Command1_Click ()
' Set Cancel to True.
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
'Set the Flags property.
CommonDialog1.Flags = cdlCFBoth Or cdlCFEffects
' Display the Font dialog box.
CommonDialog1.ShowFont
' Set text properties according to user's selections.
txt1.Font.Name = CommonDialog1.FontName
txt1.Font.Size = CommonDialog1.FontSize
txt1.Font.Bold = CommonDialog1.FontBold
txt1.Font.Italic = CommonDialog1.FontItalic
txt1.Font.Underline = CommonDialog1.FontUnderlin
txt1.FontStrikethru = CommonDialog1.FontStriketh
txt1.ForeColor = CommonDialog1.Color
Exit SubErrHandler:
' User pressed Cancel button.
Exit Sub
End Sub
Private Sub mnuFilePrint_()
Dim BeginPage, EndPage, NumCopies, Orientation, i
' Set Cancel to True.
CommonDialog1.CancelError = True
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
Orientation = CommonDialog1.Orientation
For i = 1 To NumCopies
' Put code here to send data to your printer.
Printer.ForeColor = txt1.ForeColor
Printer.FontBold = txt1.FontBold
Printer.FontItalic = txt1.FontItalic
Printer.FontUnderline = txt1.FontUnderline
Printer.FontStrikethru = txt1.FontStrikethru
Printer.FontSize = txt1.FontSize
Printer.CurrentX = 1247
Printer.CurrentY = 2438
Printer.Print txt1.Text
I would really appreciate any help that anyone could offer.
Thank you.
CSTANG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
' Printer.ForeColor = txt1.ForeColor
' Printer.FontBold = txt1.FontBold
' Printer.FontItalic = txt1.FontItalic
' Printer.FontUnderline = txt1.FontUnderline
' Printer.FontStrikethru = txt1.FontStrikethru
' Printer.FontSize = txt1.FontSize
Set Printer.Font = txt1.Font
Printer.CurrentX = 1247
Printer.CurrentY = 2438
Printer.Print txt1.Text
Try it and see!