Solved

Print Properties

Posted on 2000-04-01
7
146 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 27

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 27

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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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 27

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 27

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access query that references subform 5 47
clicking a shape in a frame array vb6 3 45
Problem to With line 4 57
Excel Automation VBA 19 67
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

785 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