?
Solved

RichTextBox.SelPrint

Posted on 1998-07-28
4
Medium Priority
?
416 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 300 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses
Course of the Month8 days, 5 hours left to enroll

765 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