批量生成账单后,弄了两种导出方式,一种是直接批量导出,另一种是一个文件一个文件打开后再保存。代码分别如下一次性批量导出:
Dim nf1 As Integer = e.Form.Controls("NF").value
Dim yf1 As Integer = e.Form.Controls("YF").value
Dim fl As String
Dim tm As String = ProjectPath & "Attachments\货款确认函.docx"
For Each r As Row In Tables("客户货款确认函_Table1")
If yf1 >= 10 Then
fl = "C:\Users\Public\Documents\货款确认函\" & r("品牌事业部") & "\" & r("业务系统编号") & r("客户名称") & nf1 & yf1 & ".docx"
Else
fl = "C:\Users\Public\Documents\货款确认函\" & r("品牌事业部") & "\" & r("业务系统编号") & r("客户名称") & nf1 & "0" & yf1 & ".docx"
End If
Dim wrt As New WordReport(Tables("客户货款确认函_Table1"), tm, fl)
wrt.BuildOne(r)
wrt.Quit()
Next
单个文件打开再保存:
Dim tm As String = ProjectPath & "Attachments\货款确认函.docx"
Dim fl As String = ProjectPath & "Reports\货款确认函.docx"
Dim wrt As New WordReport(Tables("客户货款确认函_Table1"),tm,fl)
wrt.Build()
wrt.Show()
结果,使用一次性批量导出方式会提示以下错误:由于文件许可权错误,Word无法完成保存操作。然后只导出第一个文件,后面的就导不出来了
而采用单个文件打开再保存的方式不会有问题