I need some help with printing a label from file. I have a code that writes to the Zebra printer.
What I need is to change my code to read from file and then send that to printer to print the label. As if i need to change something I will have to change only in my file not in the program.
My code
------------------------
sFolder = c\test\test.zpl
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(sFolder) Then
fso.CreateFolder (sFolder)
End If
sPort = "LPT1:"
lCount = 0
Dim i As Integer
For i = 1 To mxlabels
Set txtfile = fso.CreateTextFile(sFileName, True)
If Label = "test" Then
txtfile.WriteLine ("^XA")
txtfile.WriteLine ("^PRB^FS")
txtfile.WriteLine ("^FT516,173^A0R,118,93^FD" & sQTY & "^FS")
txtfile.WriteLine ("^FO607,0^GB0,1218,2,B^FS")
txtfile.WriteLine ("^FT785,25^A0R,31,18^FDPART NO. (P)^FS")
txtfile.WriteLine ("^FT176,25^A0R,31,18^FDSERIAL" & Sfield & "^FS")
txtfile.WriteLine ("^FO404,0^GB0,1218,2,B^FS")
txtfile.WriteLine ("^FO201,0^GB0,1218,2,B^FS")
txtfile.WriteLine ("^PF0^FS")
txtfile.WriteLine ("^XZ")
End If
txtfile.Close
fso.CopyFile sFileName, sPort
'Pause after sending print job
Call cmn_sDoEvents(200)
Next
------------------------
What I need is to change my code to read from file and then send that to printer to print the label. As if i need to change something I will have to change only in my file not in the program.
My code
------------------------
sFolder = c\test\test.zpl
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(sFolder) Then
fso.CreateFolder (sFolder)
End If
sPort = "LPT1:"
lCount = 0
Dim i As Integer
For i = 1 To mxlabels
Set txtfile = fso.CreateTextFile(sFileName, True)
If Label = "test" Then
txtfile.WriteLine ("^XA")
txtfile.WriteLine ("^PRB^FS")
txtfile.WriteLine ("^FT516,173^A0R,118,93^FD" & sQTY & "^FS")
txtfile.WriteLine ("^FO607,0^GB0,1218,2,B^FS")
txtfile.WriteLine ("^FT785,25^A0R,31,18^FDPART NO. (P)^FS")
txtfile.WriteLine ("^FT176,25^A0R,31,18^FDSERIAL" & Sfield & "^FS")
txtfile.WriteLine ("^FO404,0^GB0,1218,2,B^FS")
txtfile.WriteLine ("^FO201,0^GB0,1218,2,B^FS")
txtfile.WriteLine ("^PF0^FS")
txtfile.WriteLine ("^XZ")
End If
txtfile.Close
fso.CopyFile sFileName, sPort
'Pause after sending print job
Call cmn_sDoEvents(200)
Next
------------------------