God I hate to admit it but I don't know how to print files in VB !
I use the common dialog to set everything the user wants but I don't find anything to launch the printing sequence...
Please feel sorry for me not knowing this and help me out
:-)
Printable View
God I hate to admit it but I don't know how to print files in VB !
I use the common dialog to set everything the user wants but I don't find anything to launch the printing sequence...
Please feel sorry for me not knowing this and help me out
:-)
Do something like this:
Code:Printer.Print "Hello World! :-)"
Printer.EndDoc
It really depends on what you want to print:
I use VB Printer.print alot. This allow you to place data on a a page using x, y coordinates which, does ttake more time, but for me, it's not a problem.
People have suggested buying Crystal Reports or other 3rd Party, but, right now, b's Printer.print does the job for me.
You can use a for loop to print multiple pages, too.
The Printer object works just like a picture box. It also has property's like CurrentX and CurrentY.
Thanks guys but I don't want to open the file and read it all to send it to the printer, I want to send the file to the printer that's it ! Is there a way to do so ?
No, but you can do it in code like this:
Code:'read the file line by line and sent the output
'to the printer
Dim oneLine As String 'one line in the file
'open the file
Open "C:\Myfile.txt" For Input As #1
'loop through all the lines
Do
'read a line
Line Input #1,oneLine
'print the line
Printer.Print oneLine
Loop Until Eof(1)
'say that the printing has ended
Printer.EndDoc
'close the file
Close #1
If you have office on your machine, and the file is not strickly a test file, i would try using a word object... send the information you want to word and then use that to print it out... its nice becase you can also use it for print previews and jazz like that... just a suggestion.