?
Solved

Print Properties

Posted on 2000-04-01
7
Medium Priority
?
151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 150 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Technology Partners: 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

764 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