Solved

RichTextBox.SelPrint

Posted on 1998-07-28
4
387 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Yes,,,,,,. Let me know if want to try it...

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 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…

771 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

14 Experts available now in Live!

Get 1:1 Help Now