Solved

Print Properties

Posted on 2000-04-01
7
148 Views
Last Modified: 2010-05-02
I've got a RTF (Rich text Box) that I use to print some text I have.
Here's some of the code:

RichTextBox1.TextRTF = string1
CommonDialog1.ShowPrinter
Printer.Print (RichTextBox1.Text)

When I print it,  it looks really really ugly...
How do I adjust the properties so It can print in the margins, and other stuff like that.

0
Comment
Question by:aomega
  • 4
  • 3
7 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2676819
Hello aomega,
Please see this article for how to accomplish this task

Good Luck!

http://www.vbweb.co.uk/controls/rich_text_box_wysiwyg.htm
0
 
LVL 28

Accepted Solution

by:
Ark earned 50 total points
ID: 2676909
Why you use Printer.Print with RTB? RTB has its own method SelPrint. From VB help:

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
Cheers
0
 
LVL 28

Expert Comment

by:Ark
ID: 2676914
'Text from *.hlp file for sample above
'---------------------------
SelPrint Method:
'---------------------------
Sends formatted text in a RichTextBox control to a device for printing.

Syntax

object.SelPrint(hdc)

The SelPrint method syntax has these parts:

Part      Description
object      An object expression that evaluates to an object in the Applies To list.
hdc      The device context of the device you plan to use to print the contents of the control.
Remarks

If text is selected in the RichTextBox control, the SelPrint method sends only the selected text to the target device. If no text is selected, the entire contents of the RichTextBox are sent to the target device.
The SelPrint method does not print text from the RichTextBox control. Rather, it sends a copy of formatted text to a device which can print the text. For example, you can send the text to the Printer object using code as follows:

RichTextBox1.SelPrint(Printer.hDC)

Notice that the hDC property of the Printer object is used to specify the device context argument of the SelPrint method.

Note   If you use the Printer object as the destination of the text from the RichTextBox control, you must first initialize the device context of the Printer object by printing something like a zero-length string.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:AzraSound
ID: 2676923
Hello Ark,
Yes it does have its own print method but it still does not handle margins automatically
0
 
LVL 28

Expert Comment

by:Ark
ID: 2676944
Hello AzraSound,
If <RichTextBox1.TextRTF = string1>, I thing, standard method is enough. I didn't check your link yet, but I thing its code base on famous <smile> MS code http://support.microsoft.com/support/kb/articles/Q146/0/22.asp. All samples I've seen at the Web are the same with some additional controls (buttons, checkboxes etc.)
Cheers
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2676950
Indeed Ark it is an extract from the MS article.  However experience I have had with RTF requires I use the code for WYSIWYG printing.  Otherwise my margins are also lost in the print.
0
 
LVL 28

Expert Comment

by:Ark
ID: 2676978
It's Microsoft solution - to make OCX (or anything other) and then issue numerous SPs or PRB articles. Why don't try vbaccelerator richtextcontrol wich based on new RichEd20.dll with many new futures.
Cheers
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question