hi
I have a text file created from within VB. I need to print it. I have been using DOS command till now "shell(type filename > prn)" but that was to printer connected at LPT. Now it is laser printer connected at USB or COMM port.
I am a beginner....
Thanks
VKV
- Follow via:
- RSS
- Email Alert
Question
0
Votes
Answers (4)
0
Votes
Printing from dos
To print from dos to a non-LPT printer, you need to:
1. Share the printer using the Print and Faxes control panel
2. Open a command prompt
3. Type NET USE LPT1 \\computername\printershare
or some other LPT port.
4. Now print as normal e.g. TYPE >LPT1: myfile
5. Alternatively you could create a RichTextBox in VB and use one of its methods to print the text in the RTB.
1. Share the printer using the Print and Faxes control panel
2. Open a command prompt
3. Type NET USE LPT1 \\computername\printershare
or some other LPT port.
4. Now print as normal e.g. TYPE >LPT1: myfile
5. Alternatively you could create a RichTextBox in VB and use one of its methods to print the text in the RTB.
27th Oct 2007
Replies
thanx...
But i guess i cud not explain properly...
I need to print from within VB.
Can u give some command or something to start with? How to print text from RTB?
Thanx
But i guess i cud not explain properly...
I need to print from within VB.
Can u give some command or something to start with? How to print text from RTB?
Thanx
vrinda@...
27th Oct 2007
pls use a richtext box and use following code
richtextbox1.load("c:\test.txt")
RichTextBox1.SelPrint(Printer.hDC)
Happyy.. coding....!
By : Lenin Paily - Zionsoft
richtextbox1.load("c:\test.txt")
RichTextBox1.SelPrint(Printer.hDC)
Happyy.. coding....!
By : Lenin Paily - Zionsoft
zionsoft@...
18th Feb 2009
0
Votes
The Printer object is your friend
In VB6 there's a global printer object, called "Printer". You can write (using "Print") and paint (using numerous methods like "Line" or "Circle") on it very similar to the PictureBox object. The method "EndDoc" sends your stuff to the current printer.
There's also a collection named "Printers" containing all installed printers. You can use it to select where you want to print.
Mirko
There's also a collection named "Printers" containing all installed printers. You can use it to select where you want to print.
Mirko
2nd Nov 2007
0
Votes
Printer object
As someone else said, use the printer object in VB.
In simple terms:
printer.print MyTextBox.Text
printer.enddoc
There are a lot of other properties and methods you can play with.
In simple terms:
printer.print MyTextBox.Text
printer.enddoc
There are a lot of other properties and methods you can play with.
2nd Nov 2007
Replies
Thanx for the suggestion. But I need to change font size in between... some normal font size, some condensed font.... How do I do this from inside VB?
Vrinda
Vrinda
vrinda@...
21st Nov 2007
If you use a RichTextBox you can specify fonts and so on.
Alternatively, you can send the printer commands for your printer. ESC/P commands for Epson, PCL commands for HP Printer etc.
Alternatively, you can send the printer commands for your printer. ESC/P commands for Epson, PCL commands for HP Printer etc.
p.j.hutchison@...
22nd Nov 2007
0
Votes
reliable printing method
Shell "notepad.exe /P ""C:\TR\How To Print File From VB.txt""", vbNormalFocus
2nd Nov 2007

































