How I can print the content of RichTextBox with margins ?
Printable View
How I can print the content of RichTextBox with margins ?
Assuming that the RichTextBox's margins are already set:
That should print everything in the RichTextBox as is.Code:Private Sub cmdPrint_Click()
Printer.Print RichTextBox1.Text
Printer.EndDoc
End Sub
Matthew, your code doesn't print the formatting...
Code:Dim OldSelStart As Long
Dim OldSelLength As Long
OldSelStart = RichTextBox1.SelStart
OldSelLength = RichTextBox1.SelLength
RichTextBox1.SelStart = 1
RichTextBox1.SelLength = Len(RichTextBox1.Text)
RichTextBox1.SelPrint
RichTextBox1.SelStart = OldSelStart
RichTextBox1.SelLength = OldSelLength
And yours doesn't full formatting. Use the SelPrint method for it instead.
Code:RichTextBox1.SelPrint Printer.hDC