Solved

RichTextBox.SelPrint

Posted on 1998-07-28
4
389 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

947 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

23 Experts available now in Live!

Get 1:1 Help Now