Results 1 to 3 of 3

Thread: Printing RTF

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Location
    Dublin
    Posts
    7

    Post

    Does anyone know how to print the contents of an RichTextBox Control straight from VB keeping all the formats etc??

    Thanks.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    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



  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    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

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width