我觉得使用excel来做表格方便一点,这里有一个例子,你看看!! 门诊报销登记表.xls 是事先设计好格式的excel文件On Error Resume Next Dim PageNum As Integer '''打印的总的页数 Dim Sl As Integer '''每张能打印的条数 Dim c As IntegerIf Vas.MaxRows = 0 Then s = MsgBox("没有需要打印的记录!!", vbInformation, "提示") Exit Sub End If'''''找出需要打印的页数 PageNum = 1 Sl = 19 c = 1 While Not (Sl * c) >= Vas.MaxRows c = c + 1 PageNum = PageNum + 1 Wend '''''''''''''''''''''''''''''''' ''''用于显示打印状态 Frame1.Visible = True Label7.Caption = "共 " & Vas.MaxRows & " 条记录" Label5.Caption = "共 " & PageNum & " 页" Label6.Caption = "已经打印 0 页" '''''''''''''''''''For i = 1 To PageNum '''>>>>>>>>>>>>>>>>>>>>>分打印的页数 Dim xlapp As Excel.Application Dim xlbook As Excel.Workbook Dim file As String
Set xlapp = New Excel.Application 'Set xlapp = CreateObject("excel.Application") 'xlapp.Visible = False '''''隐藏excel Set xlbook = xlapp.Workbooks.Open(file) xlbook.Application.DisplayAlerts = False
With xlbook.Sheets(1)
For R = 1 To Sl For c = 1 To 15 Vas.Row = (i - 1) * Sl + R Vas.Col = c .Cells(R + 4, c) = Vas.Text If c = 6 Then .Cells(R + 4, c) = Format(Vas.Text, "yyyy-mm-dd") End If
Next Next .PageSetup.Orientation = xlLandscape .PrintOut xlapp.Visible = False xlapp.ActiveWorkbook.Saved = True xlapp.Quit Set xlbook = Nothing Set xlapp = Nothing Label6.Caption = "已经打印 " & i & "页" End With Next Frame1.Visible = False Exit Sub err: s = MsgBox(err.Description, vbInformation, "错误")
门诊报销登记表.xls 是事先设计好格式的excel文件On Error Resume Next
Dim PageNum As Integer '''打印的总的页数
Dim Sl As Integer '''每张能打印的条数
Dim c As IntegerIf Vas.MaxRows = 0 Then
s = MsgBox("没有需要打印的记录!!", vbInformation, "提示")
Exit Sub
End If'''''找出需要打印的页数
PageNum = 1
Sl = 19
c = 1
While Not (Sl * c) >= Vas.MaxRows
c = c + 1
PageNum = PageNum + 1
Wend
''''''''''''''''''''''''''''''''
''''用于显示打印状态
Frame1.Visible = True
Label7.Caption = "共 " & Vas.MaxRows & " 条记录"
Label5.Caption = "共 " & PageNum & " 页"
Label6.Caption = "已经打印 0 页"
'''''''''''''''''''For i = 1 To PageNum
'''>>>>>>>>>>>>>>>>>>>>>分打印的页数
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim file As String
FileCopy App.path & "\report\门诊报销登记表.xls", App.path & "\门诊报销登记表.xls"
file = App.path & "\门诊报销登记表.xls"
Set xlapp = New Excel.Application
'Set xlapp = CreateObject("excel.Application")
'xlapp.Visible = False '''''隐藏excel
Set xlbook = xlapp.Workbooks.Open(file)
xlbook.Application.DisplayAlerts = False
With xlbook.Sheets(1)
For R = 1 To Sl
For c = 1 To 15
Vas.Row = (i - 1) * Sl + R
Vas.Col = c .Cells(R + 4, c) = Vas.Text
If c = 6 Then
.Cells(R + 4, c) = Format(Vas.Text, "yyyy-mm-dd")
End If
Next
Next
.PageSetup.Orientation = xlLandscape
.PrintOut
xlapp.Visible = False
xlapp.ActiveWorkbook.Saved = True
xlapp.Quit
Set xlbook = Nothing
Set xlapp = Nothing
Label6.Caption = "已经打印 " & i & "页"
End With
Next
Frame1.Visible = False
Exit Sub
err:
s = MsgBox(err.Description, vbInformation, "错误")