I am working on a project in which a dataset is stored in thousands of Excel workbooks (currently ~ 14000) in a folder on a Sharepoint server, each of which is regularly changed to reflect changes in a subset of the data in this workbook. I know that this is not A very good way to save and update this data, but it is as it is.
I need to perform various queries related to extracting the contents of one or more fields from all books in a folder. I did this by repeating a set of books as follows:
Function getData() As Workbook
Dim resultBk As Workbook
Dim fldr As Folder
Dim fso As New FileSystemObject
Dim fileObj As File
Dim filePath As String
Dim queryBk As Workbook
'create a workbook for storing the query results
Set resultBk = Workbooks.Add(resultBkTemplatePath)
'get the folder with all the workbooks to be queried
Set fldr = fso.GetFolder(sharepointFolderPath)
For Each fileObj In fldr.Files
'try opening each of the workbooks
Set queryBk = Workbooks.Open(fileObj.Path, ReadOnly:=True)
'get data from queryBk and add it to resultBk, or add a row with an error message if queryBk failed to open
addBkDataToResults resultBk, queryBk
queryBk.Close False
Set queryBk = Nothing
Next
getData = resultBk
End Function
Sharepoint ; 12-14 . Excel, /? , open/close, ?