Hi,
We are evaluating the iceblue product.
We need to loop through all excel workbooks and worksheets in a specified folder and apply certain changes to each one. Our first step in our evaluation was to simply loop through each file and return the Count of Worksheets. The folder has 235 worksheets and one of them is "locked for editing by another user". Which is fine. In this case, i would like to nicely stop the process and inform the user which file is locked for editing. (this is not a protected file, it is locked for editing).
However, in the function that gets the worksheet count, the LoadFromFile is failing on this edit-locked spreadsheet and the try/catch is not trapping the accessviolation.
Any ideas on how I could trap this condition?
Thanks!
Public Function GetWorkSheetCount(ByVal strFilePath As String)
Dim WorkbookSource As New Workbook()
Try
WorkbookSource.LoadFromFile(strFilePath, ExcelVersion.Version2007)
Catch ex As AccessViolationException
MsgBox(ex.Message)
End Try
GetWorkSheetCount = WorkbookSource.Worksheets.Count
WorkbookSource.Dispose()
End Function