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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print file from VB 1

Status
Not open for further replies.

oneshadow

IS-IT--Management
Dec 23, 2004
125
ID
Hi all,
this may sound a simple question, but.. how to print a file from VB?

Suppose I have a txt/doc file. How can I tell printer to print this file?

Common Dialog Control.ShowPrinter does not send data to printer. We still have to code it manually.

Are there any API function to handle this?
(-:
 
I know of no simplistic way to "Print" anything from Vb. About the closest I can recommend is the "PrintForm" method. Aas far as I know, you can programattically place almost anything on a form and invoke this process to get "some" representation of the form sent to the default prointer. It does NOT respect margins or paeg size adjustments, however it CAN be used to "dump" graphics and/or text with format information.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
You can use the printer object to send data to a printer.

For instance, you could open a text file
Open FileName For Input As #FileNo

and then do something like
Do until eof(fileno)
'Allocate the contents of the current line from the file, to a string variable
Line Input #fileno, txtLine
'Add the contents of the string variable to the print method
Printer.Print txtLine
Loop

End with "printer.enddoc" to actually print it all

You can do all sorts of things with the printer object like change the font size, style, orientation - the usual stuff.

If you have access to MSDN, "Printing with the Printer Object" is a good reference.
HTH
Pete
 
How to print the file, if it is an image file(JPEG, TIFF, GIF etc) ? or if the file type is unknown till the last moment ? Example - I want to print ALL the files in a directory. How to accomplish this ? Help please.
Thank you...
RR

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top