I have the following code that grabs docx files out of a specific directory. Then another section of codes parses the tables out of them into an excel file. My problem is that the files are not being processed in order. They are being randomly grabbed. In order for my final file to have the correct data I need this be processed in order (all files start with 1,2,3..etc)
Dim MyFile As Variant
Dim Counter As Long
'Create a dynamic array variable, and then declare its initial size
Dim DirectoryListArray() As String
ReDim DirectoryListArray(1000)
'Loop through all the files in the directory by using Dir$ function
MyFile = Dir$("c:\test\output\*.*")
Do While MyFile <> ""
DirectoryListArray(Counter) = MyFile
MyFile = Dir$
Counter = Counter + 1
Loop
'Reset the size of the array without losing its values by using Redim Preserve
ReDim Preserve DirectoryListArray(Counter - 1)
Dim Loc As String
Loc = "C:\test\output\"