Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a VB Form

Status
Not open for further replies.

caguila

MIS
Mar 20, 2002
28
0
0
GB
Can anyone help with the easiest way to print a VB Form?
 
FormName.PrintForm

or

me.PrintForm

Garty
 
The function is a bit problematic,. printer error messages. Do you have any sample code using this function that overcomes these errors?
 
PrintForm Method Example
This example uses the PrintForm method to print the current form. To try this example, paste the code into the Declarations section of a form. Place on the form any controls you want to see on the printed form, and then press F5 and click the form.

Private Sub Form_Click ()
Dim Msg ' Declare variable.
On Error GoTo ErrorHandler ' Set up error handler.
PrintForm ' Print form.
Exit Sub
ErrorHandler:
Msg = "The form can't be printed."
MsgBox Msg ' Display message.
Resume Next
End Sub

 
jincy,

If you are going to copy and paste stuff straight out of help, you should at least acknowledge your source!

To use stuff straight from VB help it's easier just to post the reference, for instance:

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Thanks all. Seen the help stuff which is why i need help as all i get are errors. I was hoping answer to the printer error to be more on correctly defining the printer.
 
Try Microsoft's TechNet article Q161299. It works for any Window.
 
For those that can't find the article that Sprowler refers to, it is at:
Mind you, it's a lot of code...we've posted several shorter solution in this forum in the past. Just do a keyword search. For starters, heres a version from September 2001: thread222-134463 (it only captures the window contents, you'll have to do the printing...)
 
And here's another one, which allows you to capture any area of the screen:

thread222-243343


(oh, it's so nice to have search back up and running)
 
strongm You asked about the search engine. It is the same search engine that we had before, but now that the new servers are in place, up and running, the search engine was brought back on-line. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top