Send Wordpad (.RTF) document to Intermec label printer
Hi,
For the last two days I've been pulling my hair trying to send an .RTF file (wordpad) to an Intermec label printer from a VB6 program.
Word is not installed on user machine so it has to be Wordpad.
Here are the requirements:
1.set default printer to the Intermec
2.send a specific .rtf file to the printer
3.set default printer back to original printer
I have pretty much done this using the following code
Code:
Private Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA" (ByVal pszPrinter As String) As Long
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Sub cmdPrint_Click()
SetDefaultPrinter "Intermec" ' change default printer to Intermec
Shell ("write" & " c:\ChinaWarnings\1.rtf" & " /p") ' open WordPad, send file to printer
Sleep 2000 ' wait till print finishes
SetDefaultPrinter "Kyocera Mita KM-3035 KX" ' change default printer back
End Sub
The only problem is that I need to print multiple copies and I don't think I can specify the "number of pages" using this method as Wordpad doesn't support COM automation.
Maybe there is another method?
Please help, my head hurts...
Re: Send Wordpad (.RTF) document to Intermec label printer
Is there a reason why you can't do this via VB6's RichTextbox control? Something unusual about the documents or the printer?
Re: Send Wordpad (.RTF) document to Intermec label printer
Hi dilettante,
I can load the text into a RichTextBox but not sure how to print it to fit the 3"x2.25" labels.
Can you give a simple example?
Re: Send Wordpad (.RTF) document to Intermec label printer
The .rtf documents I'm trying to print contain English and Chinese characters.
When I load the file into RichTextBox I can see the English and Chinese chars, however when I print them the chinese characters are replaced by ??? or escape characters.
The following prints chinese characters as ???
Code:
txtBox.LoadFile App.Path & "\" & "china.parts.not.treated.rtf"
Printer.Print txtBox.Text
Printer.EndDoc
The following prints printer code
Code:
txtBox.LoadFile App.Path & "\" & "china.parts.not.treated.rtf"
Printer.Print txtBox.TextRTF
Printer.EndDoc
Re: Send Wordpad (.RTF) document to Intermec label printer
Try using the RTB's SelPrint method.
Re: Send Wordpad (.RTF) document to Intermec label printer
SelPrint method works but I can't select multiple copies of the label.
I can print in a loop with printer.NewPage but that is really slow if you want to print 100 labels.
I'm almost ready to give up and get an off shelf program to do this...
Re: Send Wordpad (.RTF) document to Intermec label printer
Are you sure you can't set the number of copies on the Printer object before using its hDC with the SelPrint method?
Re: Send Wordpad (.RTF) document to Intermec label printer
When I do this:
Code:
Printer.Copies = 1
txtBox.SelPrint Printer.hDC, False
I get the following error:
"Runtime error 396: Copies property can not be set within a page"
Am I using the wrong property?
Re: Send Wordpad (.RTF) document to Intermec label printer
I had the idea this was a VB5 bug fixed in VB6:
FIX: Cannot Change Page Settings During Print Job
Do you have VB6 SP6 installed?
Re: Send Wordpad (.RTF) document to Intermec label printer
Getting really close!
You're right, I didn't have SP6 as I just got a new laptop with windows 7 & VB6.
I downloaded and installed the SP6setup.
Now with the code below it prints multiple copies.
Code:
Printer.Copies = 3
txtBox.SelPrint Printer.hDC, True
The only problem is it prints blank labels in between. However when I switch to printing on a laser printer, it doesn't do that. So it might have an issue with the Intermec IPL language that the label printer is using.
Re: Send Wordpad (.RTF) document to Intermec label printer
You may not need the new page statement when working with the label printer.
Have you tried omitting that?
Re: Send Wordpad (.RTF) document to Intermec label printer
Yes, I only have those two lines. (no .NewPage, not even .EndDoc)
Re: Send Wordpad (.RTF) document to Intermec label printer
Could be a printer setting, I seem to remember some printers having a setting to spit out a blank label under some conditions.
Another thing that may cause this would be if your label is slightly larger than the label size, perhaps the last line feed is pushing out a new but blank label