If Tables("客户数据").current IsNot Nothing Then '如果存在符合条件的行
Dim xm As String = Tables("客户数据").current("第一列")
Dim htbh As String = Tables("客户数据").current("合同编号")
Dim tm As String = ProjectPath & "Attachments\合同模板.docx" '指定模板文件
Dim fl As String = ProjectPath & "Reports\合同\" & xm & "-" & htbh & ".docx" '指定目标文件
Dim wrt As New WordReport(Tables("客户数据"),tm,fl) '定义一个WordReport
wrt.Build()
wrt.Show() '显示报表
End If
=====================================
错误提示:
无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft.Office.Interop.Word._Application”。此操作失败的原因是对 IID 为“{00020970-0000-0000-C000-000000000046}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: 库没有注册。 (异常来自 HRESULT:0x8002801D (TYPE_E_LIBNOTREGISTERED))。