以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  保存Excel 报表后改名复制  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=84662)

--  作者:wusim
--  发布时间:2016/5/6 20:06:00
--  保存Excel 报表后改名复制
请问能不能生成报表后不打开文件,将文件名复制到项目目录下出库单(ProjectPath &出库单 ),粘贴后然后将文件改成与出厂编号相同+生成后报表名(如:出厂编号是101,文件就改成101出库单.xls),才打开这个改名后的文件。

Dim Book As New XLS.Book(ProjectPath & "Attachments\\出库单.xls")
Dim
fl As String = ProjectPath & "Reports\\出库单.xls"
Book.Build()
\'生成细节区

FileSys.CopyFile(ProjectPath & "Reports\\出库单.xls", "ProjectPath & "出库单\\???.xls"",True) 怎样改

Dim Proc As New Process \'打开工作簿
Proc.File = fl
Proc.Start()


--  作者:Hyphen
--  发布时间:2016/5/7 8:54:00
--  
Dim Book As New XLS.Book(ProjectPath & "Attachments\\出库单.xls")
Dim fl As String = ProjectPath & "Reports\\出库单.xls"
Book.Build() \'生成细节区
dim fl2 as string = "ProjectPath & "出库单\\" & Tables("出库单").Current("出厂编号") &  "出库单.xls"
FileSys.CopyFile(fl, fl2,True) 怎样改
Dim Proc As New Process \'打开工作簿
Proc.File = fl2
Proc.Start()


--  作者:wusim
--  发布时间:2016/5/7 13:16:00
--  
增加一个判断语句,当存在相同文件名文件时,提示“已存在相同文件,是否覆盖”按“是”覆盖 按“否”取消,只打开已存在的文件。

Dim Book As New XLS.Book(ProjectPath & "Attachments\\告知书.xls")
Dim fl As String = ProjectPath & "Reports\\告知书.xls"
Book.Build() \'生成细节区
Dim fl2 As String = ProjectPath & "告知书\\" & Tables("基本信息表").Current("出厂编号") &  "告知书.xls"
If FileSys.FileExists(f12) Then
    Dim Result As DialogResult
    Result = MessageBox.Show("存在相同文件!","是否覆盖", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Result = DialogResult.Yes Then
        FileSys.CopyFile(fl, fl2,True)
        Dim Proc As New Process \'打开工作簿
        Proc.File = fl2
        Proc.Start()
    Else
        Dim Proc As New Process \'打开工作簿
        Proc.File = fl2
        Proc.Start()
    End If
Else
    FileSys.CopyFile(fl, fl2,True)
    Dim Proc As New Process \'打开工作簿
    Proc.File = fl2
    Proc.Start()
End If

哪里错了,是不是这句:If FileSys.FileExists(f12) Then 

[此贴子已经被作者于2016/5/7 13:47:15编辑过]

--  作者:Hyphen
--  发布时间:2016/5/7 13:39:00
--  
http://www.foxtable.com/help/topics/0326.htm,看示例五
--  作者:wusim
--  发布时间:2016/5/7 14:07:00
--  
已解决 改成If FileSys.FileExists(ProjectPath & "告知书\\" & Tables("基本信息表").Current("出厂编号") &  "告知书.xls") Then