Link to home
Start Free TrialLog in
Avatar of b3cf
b3cf

asked on

How to print the contents of a Rich Text box

Hi,

  Could someone advice me on how I could print the contents of a Rich Text box.

Any help is greatly appreciated.

Thanx
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Did you try:

RichTextBox1.SelPrint

Anthony
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

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
slight correction to anthony's first post: shouldn't it be RichTextBox1.SelPrint Printer.hDC ?

.SelPrint will tell the rich text box to print the Selected portion of the text.
You might want to say before that:

.SelStart = 0
.SelLength = len(.Text)
Avatar of DennisBorg
DennisBorg

bobbit31:

>slight correction to anthony's first post:
>shouldn't it be RichTextBox1.SelPrint Printer.hDC ?

The Common Dialog control would not automatically change the printer referenced by the Printer object.

Here is an excerpt from the VB Documentation:

   With a CommonDialog control, this property returns a
   device context for the printer selected in the Print
   dialog box when the cdlReturnDCflag is set or an
   information context when the cdlReturnIC flag is set.


> The Common Dialog control would not automatically
i said his first post ;)
So there is no confusion, please ignore my first post and use something similar to what I posted in my second post together with ventond's code.

Anthony
>i said his first post ;)

Oh!  Oops!   ;)