在针式打印机上可以实现按"行"来打印,在喷墨和激光打印机上只能按"页"打印。
给你个例子参考吧,这是个笨方法!
先将需要打印的数据写入文件
Open "c:\temp\jj.txt" For Output As #1
Print #1,
Print #1, Tab(16); "过磅日结单"
Print #1, Tab(2); "日期:" & Str(Adodc1.Recordset("日期"))
Print #1, Tab(2); "业务数:" & Str(jls) & "
车"
Print #1, Tab(2); "总毛重:" & Str(zmz) & "
吨"
Print #1, Tab(2); "总净重:" & Str(zjz) & "
吨"
Print #1, Tab(2); "过磅费:" & Str(gbf) & "
元"
Print #1,
Print #1,
Print #1,
Print #1,
Print #1,
Print #1,
Close #1
然后调用打印机打印数据文件
Dim Submit As String
Dim prn As Printer
Submit = UCase(Trim("c:\temp\jj.txt"))
If Not IsFile(Submit) Then
MsgBox "文件未找到: " & Submit, vbExclamation, "Error"
Exit Sub
End If
For Each prn In Printers
If InStr(cmbprint, prn.DeviceName) = 1 And Right(cmbprint, Len(prn.Port)) = prn.Port Then
Call SpoolFile(Submit, prn.DeviceName)
Exit For
End If
Next prn