Does anyone know how to print the contents of an RichTextBox Control straight from VB keeping all the formats etc??
Thanks.
Printable View
Does anyone know how to print the contents of an RichTextBox Control straight from VB keeping all the formats etc??
Thanks.
Try this:
Printer.Print 'Call this so the printer object has a hDC
Call RichTextBox1.SelPrint(Printer.hDC)
Printer.EndDoc
Good luck!
------------------
Joacim Andersson
[email protected]
[email protected]
www.YellowBlazer.com
From MSDN:
SelPrint Method Example
This example prints the formatted text in a RichTextBox control. To try this example, put a RichTextBox control, a CommonDialog control, and a CommandButton control on a form. Paste this code into the Click event of the CommandButton control. Then run the example.
Code:Private Sub Command1_Click()
CommonDialog1.Flags = cdlPDReturnDC + cdlPDNoPageNums
If RichTextBox1.SelLength = 0 Then
CommonDialog1.Flags = CommonDialog1.Flags + cdlPDAllPages
Else
CommonDialog1.Flags = CommonDialog1.Flags + cdlPDSelection
End If
CommonDialog1.ShowPrinter
Printer.Print ""
RichTextBox1.SelPrint CommonDialog1.hDC
End Sub
------------------
Mark Sreeves
Analyst Programmer
[email protected]
A BMW Group Company