Gh0st
2005-03-16 14:03:16 UTC
I want to access an Network Printer via Zebra-Language. With VB6 it's
no problem and works, but with VBS the Printer.Print funktion doesn't
work.
So I tried to map my Printer to the LPT4 Port and wanted via the
FileSystemObject
--------------------------------------------------------------------------
call GetPrinters
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "LPT4", "\\192.168.0.181\" &
Printer_Ori
Set ff = CreateObject("scripting.FileSystemObject")
Set Pr = ff.OpenTextFile("LPT4", 2, True, 0)
Pr.writeline "^XA" & Chr(13)
Printer.Print "^FDDEMOTEXT^FS" & Chr(13)
Pr.writeline "^XZ" & Chr(13)
Pr.Close
Sub GetPrinters
Set oprinters = CreateObject("WScript.Network").EnumPrinterConnections
For i = 0 To oprinters.Count - 1 Step 2
If InStr(LCase(oprinters.Item(i + 1)), "Labelprinter") Then
PRINTER_Label = oprinters.Item(i + 1)
Exit For
End If
Next
Printer_Ori = GetDefaultPrinter
End Sub
--------------------------------------------------------------------------
But the next problem is to find the right Printername. In Printer_Ori
is the Name like my Printer is called in Windows. But this is not the
name the AddWindowsPrinterConnection Functions want's to know.
Can someone perhaps tell me please where I get the correct Name? Or a
better Idea how to talk to my Network-Printer (perhaps similar to
Printer.Print under VB6)
no problem and works, but with VBS the Printer.Print funktion doesn't
work.
So I tried to map my Printer to the LPT4 Port and wanted via the
FileSystemObject
--------------------------------------------------------------------------
call GetPrinters
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "LPT4", "\\192.168.0.181\" &
Printer_Ori
Set ff = CreateObject("scripting.FileSystemObject")
Set Pr = ff.OpenTextFile("LPT4", 2, True, 0)
Pr.writeline "^XA" & Chr(13)
Printer.Print "^FDDEMOTEXT^FS" & Chr(13)
Pr.writeline "^XZ" & Chr(13)
Pr.Close
Sub GetPrinters
Set oprinters = CreateObject("WScript.Network").EnumPrinterConnections
For i = 0 To oprinters.Count - 1 Step 2
If InStr(LCase(oprinters.Item(i + 1)), "Labelprinter") Then
PRINTER_Label = oprinters.Item(i + 1)
Exit For
End If
Next
Printer_Ori = GetDefaultPrinter
End Sub
--------------------------------------------------------------------------
But the next problem is to find the right Printername. In Printer_Ori
is the Name like my Printer is called in Windows. But this is not the
name the AddWindowsPrinterConnection Functions want's to know.
Can someone perhaps tell me please where I get the correct Name? Or a
better Idea how to talk to my Network-Printer (perhaps similar to
Printer.Print under VB6)