Solved

RichTextBox.SelPrint

Posted on 1998-07-28
4
401 Views
Last Modified: 2012-06-21
How can I print all pages of a document (with 3 pages on WinWord, for example) put into a RichTextBox control? Using the sample at SelPrint help topic DO NOT works!
0
Comment
Question by:pplopes
  • 2
4 Comments
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1467035
One possibility is a Hidden RTF box array, one RTF per page,,,,Then copy one page worth to each RTF...... Then use the print form method... What do you think...

0
 
LVL 12

Accepted Solution

by:
mark2150 earned 100 total points
ID: 1467036
Buried in a note on the SELPRINT command is that you have to initialize the printer device *first*. Any you're right, the example code does NOT work (thanx M$) In this example the RichTextBox is called RESULT. Try this:

Private Sub btn_print_Click()
'
' Print requested, check for printer type and bail if oper says nogo
'
If Not armprinter Then GoTo drain
'
Dim workstring As String
'
Label1.Caption = ". . . printing . . ."
'
Printer.Font = "arial"
Printer.FontSize = 10
'
' Print - could be many pages
'
Printer.Print " "
result.SelPrint (Printer.hDC)
'
On Error Resume Next
Printer.EndDoc
'
drain:
Label1.Caption = ""
End Sub

Public Function armprinter() As Boolean
'
' This function is used to determine if printing is required
' The big savings is that any form can call us and that
' particular form doesn't need a COMMONDIALOG object locally
' to determine if printing is switched on. This function returns
' a logical:
'
'   TRUE - Print
'   FALSE - Cancel
'
' Thus the caller can simply use:
'
'   if not armprinter then goto {abort label}
'
' Pretty slick, eh?
'
armprinter = True
On Error GoTo trapped
CommonDialog1.Flags = 0
CommonDialog1.CancelError = True
CommonDialog1.ShowPrinter
'
' We make it here then user said OK to print, pass default
' value back
'
GoTo drain
' =================
'
' Here on error trap of [Cancel], pass falsity back
'
trapped:
armprinter = False
Resume drain
' = = = = = = No fallthru
'
drain:
End Function

0
 

Author Comment

by:pplopes
ID: 1467037
Are you suggesting one visible richtextbox with all rtf-winword text and three hidden richtextboxes each one with one page of rtf-winword text? How can I print hidden controls using printform?
0
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1467038
Yes,,,,,,. Let me know if want to try it...

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…

730 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