加上一行,这样关闭本次生成的报表,才会生成下一个,不会带来冲突:
If Forms("选项").Controls("ComboBox1").Value >"" AndAlso Forms("选项").Controls("ComboBox2").Value >"" Then
For i As Integer = 0 To Tables("申请表").Rows.Count -1 Step 1370
With Tables("申请表")
.Select(i, 0, math.min(i + 1369,.rows.count -1), .cols.count -1)
End With
Dim Book As New XLS.Book(ProjectPath & "Attachments\登记表.xls") '打开模板
Book.Build() '生成细节区
Book.Save("d:\My Documents\Reports\登记表.xls") '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File ="d:\My Documents\Reports\登记表.xls"
proc.WaitForClose = True
Proc.Start()
Next
END IF