Solved

Print Properties

Posted on 2000-04-01
7
144 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now