以文本方式查看主题

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

--  作者:yongxuanchen
--  发布时间:2015/6/7 0:05:00
--  难题

Dim tm As String  = ProjectPath & "Attachments\\1.doc" \'指定模板文件
Dim fl As String = ProjectPath & "Reports\\1.doc" \'指定目标文件
Dim wrt As New WordReport(Tables("信息表"),tm,fl) \'定义一个WordReport
wrt.Build() \'生成报表
\'wrt.Show() \'显示报表
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
catch ex As exception
    msgbox(ex.message)
finally
    app.Quit
 End try
Dim Proc As New Process
Proc.File =  "Reports\\1.doc"  \' 指定要执行的文件
Proc.Start()

 

这段代码在程序发布后,在生成报表时出错,提示系统找不到指定文件。请问是不是要在发布的时候添加附件才可以,程序在开发文件中完全正常运行。求解决方法

[此贴子已经被作者于2015/6/7 0:07:06编辑过]

--  作者:sloyy
--  发布时间:2015/6/7 0:57:00
--  
不用 ,发布的时候,Attachments目录包括里面的模版文件,都一起发布了,是不是新安装程序这台机子没有安装office?
你分段检查程序看看,
Reports目录里是否生成了1.doc
2 加了密码后, Reports目录里是否还有1.doc

--  作者:大红袍
--  发布时间:2015/6/7 9:44:00
--  

Dim Proc As New Process
Proc.File =  "Reports\\1.doc"  \' 指定要执行的文件
Proc.Start()

 

写成

 

Dim Proc As New Process
Proc.File =  fl

Proc.Start()