Re: Printing to only USB printer
- From: "F L A S H" <flash@xxxxxxxxx>
- Date: Wed, 28 Sep 2005 19:38:57 GMT
Yeah I am sure. It works on my Win 98 machine but not my XP machine. The
device name is "Zebra LP2844"
Yes I used your vbCompare code and it still didn't work and the printer is
directly attached to my local machine..
The common control printer dialog works though...
Very weird...
This may be way out of whack but i'm a VB newbie and this is the only way I
know how to code this... It seems very simple but I may be making it too
difficult...
Public Function PrintFunction()
Dim Print_Line As String
Dim numlabels As Long
Dim Print_ProConst As String
Dim i As Long
Dim OldDefaultPrinter As String
Dim Pr As Printer
Printer.ScaleMode = vbTwips
Print_Line = Val(txtPro.Text)
numlabels = Val(txtNumPros.Text)
Print_ProConst = "pro:"
For Each Pr In Printers
If InStr(1, Pr.Port, "USB001", vbTextCompare) > 0 Then
' Found a USB Printer
Set Printer = Pr
Exit For
End If
Next Pr
If Printer Is Nothing Then
Beep
MsgBox "No Label Printer Found", vbOKOnly + vbExclamation, "No Label
Printer"
Else
OldDefaultPrinter = SetPrinterAsDefault(Printer.DeviceName)
If Print_Line = 0 Then
Beep
MsgBox "Please enter a pro number to print.", vbOKOnly +
vbExclamation, "Need Input..."
txtPro.SetFocus
ElseIf numlabels = 0 Then
Beep
MsgBox "Please enter number of labels to print.", vbOKOnly +
vbExclamation, "Need Input..."
txtNumPros.SetFocus
Else
For i = 1 To numlabels
Printer.Font = "arial": Printer.FontSize = 15: Printer.FontBold
= False
Printer.Print Print_ProConst; Spc(1);
Printer.Font = "arial": Printer.FontSize = 60: Printer.FontBold
= True
Printer.Print Print_Line
On Error Resume Next
Call ClearTextBoxes(Me)
txtPro.SetFocus
Printer.NewPage
Next i
Printer.EndDoc
SetPrinterAsDefault (OldDefaultPrinter)
End If
End If
End Function
"Mike Williams" <Mike@xxxxxxxxxxxxxxxxx> wrote in message
news:dhc72g$282$1@xxxxxxxxxxxxxxxxxxxxxxx
> "F L A S H" <flash@xxxxxxxxx> wrote in message
> news:_eg_e.97590$Ph4.3069069@xxxxxxxxxxxxxxxxxxxxxxxxxx
>
>> Hi, I tried that but it still prints to the windows default printer in
>> XP...
>
> Unusual. I use a simple "single user" XP setup myself, but I'm fairly
> certain that selection of desired output printer is a "user setting" and
> that all users can do it. I've a few different printers and faxes and thin
> gs on my own XP machine and the abocve code works fine. Are you sure that
> the driver name of your USB printer actually contains the text USB0001?
> What is the device name of the USB printer. Try printing out all attached
> dcevice names just to check. Then try the code again, this time looking
> for part of the device name (by the way, are you sure that you used my own
> suggested code, which uses vbTextCompare (rather than your original code,
> which doesn't)? Post the *exact* code that you are using (including the
> code to search for and set the printer and some test code that you then
> use to print something to it), and also tell us the *exact* device name of
> your USB printer. Also, is this USB printer connected to your own local
> machine?
>
> What about the CommonControl Printer Dialog? Does that allow you to find
> and select your USB printer? Actually check it out for me, and tell me
> whether it does.
>
> Mike
>
>
.
- Follow-Ups:
- Re: Printing to only USB printer
- From: Mike Williams
- Re: Printing to only USB printer
- From: Mike Williams
- Re: Printing to only USB printer
- References:
- Printing to only USB printer
- From: F L A S H
- Re: Printing to only USB printer
- From: Mike Williams
- Re: Printing to only USB printer
- From: F L A S H
- Re: Printing to only USB printer
- From: Mike Williams
- Printing to only USB printer
- Prev by Date: Re: Creating panel & pictureBox from within a thread
- Next by Date: Re: Printing to only USB printer
- Previous by thread: Re: Printing to only USB printer
- Next by thread: Re: Printing to only USB printer
- Index(es):
Relevant Pages
|