老师 尝试了一下 没有成功 还得继续麻烦老师 谢谢!
当前代码如下:【第四页并没有被删除,刚好第四页是末尾页,另外如果我要删除3.4页,下述红色部分代码我该怎么写呢】
Dim tm As String = ProjectPath & "Attachments\谈话通知书.doc" '指定模板文件
Dim fl As String = ProjectPath & "Reports\谈话通知书.doc" '指定目标文件
Dim fl2 As String = ProjectPath & "Reports\谈话通知书.pdf" '指定目标文件
Dim wrt As New WordReport(Tables("谈话通知书"),tm,fl) '定义一个WordReport
wrt.Build() '逐行生成报表
wrt.SaveToPDF(fl2) '保存为PDF文件
wrt.Quit() '退出
Dim pages As Integer
Dim app As New MSWord.Application
try
Dim doc = app.Documents.Open(fl)
Dim range1 = doc.GoTo(1, Which:=1, Count:=4) '第几页就把Count:=5改为几,比如第三页:Count:=3
Dim range2 = range1.GoToNext(1)
doc.Range(range1.Start,range2.Start).Delete(1,1)
doc.save
Doc.close
catch ex As exception
msgbox(ex.message)
finally
app.Quit
End try
Dim Proc As New Process '打开PDF文件
Proc.File = fl
Proc.Start()
[此贴子已经被作者于2022/2/12 15:55:01编辑过]