The following method allows you to save a Microsoft Excel file to a users hard disc.
Source Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
' @Author - Alexander Bolte' @ChangeDate - 2015-01-05' @Description - Saves provided excel file under given file path.' Overwrites any existing file in same directory with same name.' @Param xlFile - An object of type Excel.Workbook.' @Param trgPath - A String holding a path to save a provided file to.' @Returns true, if a provided excel file has been saved successfully' else false.FunctionsaveXlFile(xlFile,trgPath)' As BooleanDimret' As BooleanDimfso' As Scripting.FileSystemObjectOnErrorResumeNext' Delete file if it already exists.deleteFileOnHDtrgPath' Save provided file under given file path.xlFile.SaveAstrgPathret=TrueIfErr.Number<>0ThenErr.ClearEndIfsaveXlFile=retEndFunction