Saving an Excel workbook is a rather simple task. However you have to regard many things in IO operations, which can go wrong.
Therefore it is always good to add some extra exception handling for IO operations that are likely to fail.
Hence, although saving a workbook requires only one line of code I use below method for saving workbooks.
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
' @Author - Alexander Bolte' @ChangeDate - 2014-10-26' @Description - Saving handed workbook under provided path.' @Param wrk - an initialized object of type Workbook.' @Param trgPath - a String holding the target path the handed workbook to be saved to.' @Returns - true, if the Workbook has been saved successfully, else false.' @Remarks - the workbook is handed by reference. Therefore the calling function has to take care of closing it properly after has been saved.' This function is only saving a handed workbook.PublicFunctionsaveWorkbook(ByRefwrkAsWorkbook,ByValtrgPathAsString)AsBooleanDimisSavedAsBooleanOnErrorGoToerrHandle:wrk.SaveAstrgPathisSaved=TrueerrHandle:IfErr.Number<>0ThenErr.ClearEndIfsaveWorkbook=isSavedEndFunction