没办法,试试这样,一个一个的生成。
Dim Result As DialogResult
Result = MessageBox.Show("将按照模板生成预览文书,但不会保存,可供打印!"& vbcrlf &"你可以选中多行行头,批量预览文书!"& vbcrlf &"是---预览"& vbcrlf &"否---返回", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
'预览和生成分开处理,用下面代码预览
Dim st As Date = Date.Now '开始计时
Dim tm As String = ProjectPath & "Attachments\通知书正本.doc" '指定模板文件
With Tables("通知_table1")
If .TopPosition > -1 Then '如果选定区域包括数据行
Dim prs As Integer = 20
For p As Integer = 0 To math.Ceiling((.bottomposition-.Topposition+1) / prs) - 1
Dim fileName As String = ProjectPath & "Reports\应诉通知书\预览" & p & ".doc" '指定目标文件
Dim wrt As New WordReport(Tables("通知_table1"),tm,fileName) '定义一个WordReport
For i As Integer = p * prs To math.min(.bottomposition-.topposition,( p + 1) * prs - 1)
application.Doevents
Dim r As Row = .Rows(.Topposition +i)
wrt.BuildOne(r)
wrt.RecordsOnEachPage =1
Next
wrt.quit
Dim proc As new Process
proc.File = filename
proc.start
Next
End If
End With
MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒")
Else
Return
End If