Re: Printing to only USB printer



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
>
>


.



Relevant Pages

  • Re: ScriptText - ActiveScriptEventConsumer - Create
    ... And this machine is local machine that is where you launch the script also. ... > Dim objInstOfEventFilter ...
    (microsoft.public.win32.programmer.wmi)
  • Listing, adding, and removing users to a local or domain group
    ... This code will list the users on the local machine using the ... Purpose: This will list the users in a domain. ... Dim domainDirectory As New DirectoryEntry ... directorySearcher.PropertiesToLoad.AddRange(New String() {"givenName", ...
    (microsoft.public.windows.server.active_directory)
  • Re: How do I run IPConfig /all Programmatically?
    ... > How do I run 'IPConfig /all' Programmatically? ... > all IP and MAC addresses which are active on the local machine. ... Dim file As String ...
    (microsoft.public.vb.winapi)
  • web service application
    ... I intend having a program which can load the details of a remote web ... ' Wrap the response stream with a text-based reader ... Dim sr As New StreamReader) ... than the local machine. ...
    (microsoft.public.dotnet.faqs)
  • Printing in remote desktop session
    ... I have remote desktop running on my local machine and someone connecting from ... I tried to install the ... have any suggestions on how to install a USB printer without having the ...
    (microsoft.public.windowsxp.work_remotely)