根据上面老师指导的代码,运行时出现问题,还得麻烦老师看看下面代码的情况
问题,下面代码的写法,能在生成PDF的同时上传文件,指定的目标列也能自动填入字符,数据库中的文件夹也有文件,但是如果要在FTP窗口点击下载该文件,无法下载报错530......(应该是文件名错误吧)
测试:如果直接在FTP窗口上传文件,点击下载,又能正常打开PDF
请老师指导,指导,谢谢!
1. 写在FileCreated
Dim r As Row = Tables("会议纪要").Current
r("附件") = r("会议议题") & ".pdf"
FileSys.CopyFile(e.FullPath, ProjectPath & "项目/Reports/会议纪要/" & r("附件"),True) '此行如果使用,点击生成报表的按钮后会出现报错提示“未能找到文件项目/Reports/会议纪要/mso.24B4.tmp" 有时是mso.1FE8
2.写在按钮
Dim tm As String = ProjectPath & "Attachments\会议纪要.doc" '指定模板文件
Dim fl1 As String = ProjectPath & "Reports\会议纪要.doc" '指定目标文件
Dim fl2 As String = ProjectPath & "Reports\会议纪要\ " & Tables("会议纪要").current("会议议题") & ".pdf" '指定目标pdf文件
Dim wrt As New WordReport(Tables("会议纪要"),tm,fl1) '定义一个WordReport
wrt.Build() '逐行生成报表
wrt.SaveToPDF(fl2) '保存为PDF文件
wrt.Quit() '退出
Dim ftp1 As New FtpClient
ftp1.Host="XXX"
ftp1.Account = "XXX"
ftp1.Password = "XXX"
If ftp1.Upload(fl2,"\RQNHFJ\" & filesys.GetName(fl2)) = True Then
Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
3. 如果以下代码写在FileCreated ,点击按钮报错 WD0000002.tmp
Dim ftp1 As New FtpClient
ftp1.Host="XXX"
ftp1.Account = "XXX"
ftp1.Password = "XXX"
If ftp1.Upload(e.FullPath,"\RQNHFJ\" & r("附件")) = True Then
Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
[此贴子已经被作者于2018/7/2 9:19:41编辑过]