Link to home
Start Free TrialLog in
Avatar of Richard2000
Richard2000

asked on

SelPrint doesn't work!

I am trying to print the contents of a RichTextBox using the SelPrint method.  I have tried the example in the VB 4 SelPrint documentation which is as follows...

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
      RichTextBox1.SelPrint CommonDialog1.hDC
End Sub

But when I try it out, nothing prints!  I keyed in some text into the RichTextBox and clicked on the command button, but although there is a little disk activity (which shows something is happening), nothing prints.  How can I make this example work, so that it prints?  I have my printer set up properly as the default printer, so why isn't it working?
ASKER CERTIFIED SOLUTION
Avatar of anthonyc
anthonyc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial