If tb.Current IsNot Nothing Then
Dim cr As Row=tb.Current
Dim tm As String = ProjectPath & "Attachments\起重机检验报告模板.doc" '指定模板文件
Dim fw As String = fld & "\" & cr("InwordNo") & "检测报告.doc" '指定目标文件,含牌照号或自编号
Dim fp As String = fld & "\" & cr("InwordNo") & "检测报告.pdf" '指定目标文件,含牌照号或自编号
If FileSys.FileExists(fp) Then
Dim Result As DialogResult
Result = Messagebox.Show("文件已经存在!是否替换","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
FileSys.DeleteFile(fp,2,2) '则彻底删除之
Else
Return 0
End If
End If
Dim wrt As New WordReport(tb,tm,fw) '定义一个WordReport
wrt.BuildOne(cr)
wrt.SaveToPDF(fp) '保存为PDF文件
wrt.Quit '这个执行后,后台还有microsoft word 进程,导致下面的删除出错
If FileSys.FileExists(fw) Then
FileSys.DeleteFile(fw,2,2) '则彻底删除之
End If
'wrt.Show() '显示报表
Dim Proc As New Process '打开PDF文件
Proc.File = fp
Proc.Start()
End If