先用代码判断制定路径的文件是否存在 存在就执行打印 不存在就提示退出
If FileSys.FileExists(ProjectPath & "Attachments\打印_出货单.xls") Then
Dim Book As New XLS.Book(ProjectPath & "Attachments\打印_出货单.xls")
Dim fl As String = ProjectPath & "Reports\打印_出货单.xls"
Book.Build()
Book.Save(fl)
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Ws.PrintOut
App.Quit
Else
Messagebox.Show("未找到打印模板,请联系开发管理员!","提示")
return
End If