以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  word报表  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=80105)

--  作者:ayiken
--  发布时间:2016/1/16 11:56:00
--  word报表

老师您好!

我的word报表带代码是如下

Dim tm As String  = ProjectPath & "Attachments\\入院病历.doc" \'指定模板文件
Dim fl As String = ProjectPath & "Reports\\入院病历.doc" \'指定目标文件
Dim wrt As New WordReport(Tables("住院记录"),tm,fl) \'定义一个WordReport
wrt.Build() \'逐行生成报表
wrt.quit
Dim app As New MSWord.Application
try
    Dim fileName = fl
    Dim doc = app.Documents.Open(fileName)
    doc.Protect (Password:="123456", NoReset:=False, Type:= _
    MsWord.WdProtectionType.wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False)
    app.Documents.save
    app.Visible = True
catch ex As exception
    msgbox(ex.message)
    app.Quit
finally
   
End try

现在我不需要保护密码,就是要打开word报表后可编辑模式,上面代码改成如下,但是出现错误,请老师帮我改一下,谢谢!!!

Dim tm As String = ProjectPath & "Attachments\\入院病历.doc" \'指定模板文件
Dim fl As String = ProjectPath & "Reports\\入院病历.doc" \'指定目标文件
Dim wrt As New WordReport(Tables("住院记录"),tm,fl) \'定义一个WordReport
wrt.Build() \'逐行生成报表
wrt.quit
End try


--  作者:大红袍
--  发布时间:2016/1/16 16:33:00
--  

这段代码不应该报错,报什么错?

 

Dim tm As String = ProjectPath & "Attachments\\入院病历.doc" \'指定模板文件
Dim fl As String = ProjectPath & "Reports\\入院病历.doc" \'指定目标文件
Dim wrt As New WordReport(Tables("住院记录"),tm,fl) \'定义一个WordReport
wrt.Build() \'逐行生成报表
wrt.quit