@Orfevre
I'm missing some context here, however I noticed that your recursive 'GetFiles(ByVal path As String, r As Long)'
routine, appears to attempt to open all files located in your "D:\data\Analysis\records\" folder, including any contained within nested folders. Perhaps the routine is attempting to open a file that can't be accessed or read by the Workbooks.Open
method. The FileSystemObject (FSO) class objects - such as "File" - have access to a "Type" property you can use to check the file extension (e.g., .csv, .txt, .xls), or alternatively, you may check the extension using string routines. Have you tried using a direct reference to the "Microsoft Scripting Runtime", so that you may declare specific FSO objects, in order to access the methods?
Dim file As Object
For Each subfolder In folder.SubFolders
[...]
For Each file In folder.Files
[...]
Set fromWorkbook = Workbooks.Open(file)