PDA

Click to See Complete Forum and Search --> : Printing RTF


Greg!
Nov 23rd, 1999, 09:46 PM
Does anyone know how to print the contents of an RichTextBox Control straight from VB keeping all the formats etc??

Thanks.

Joacim Andersson
Nov 23rd, 1999, 10:08 PM
Try this:

Printer.Print 'Call this so the printer object has a hDC
Call RichTextBox1.SelPrint(Printer.hDC)
Printer.EndDoc

Good luck!

------------------
Joacim Andersson
joacim@programmer.net
joacim@yellowblazer.com
www.YellowBlazer.com (http://www.YellowBlazer.com)

Mark Sreeves
Nov 23rd, 1999, 10:18 PM
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.

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

Mark.Sreeves@Softlab.co.uk
A BMW Group Company