Solved

RichTextBox.SelPrint

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

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
Updates not working for MS Windows 7 12 164
Added a column screws up code 5 57
Help me. 3 54
Excel Automation VBA 19 67
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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

813 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

17 Experts available now in Live!

Get 1:1 Help Now