Results 1 to 2 of 2
2008-05-16, 18:35 #1
- Join Date
- Sep 2001
- Stuck at work..., Missouri, USA
- Thanked 0 Times in 0 Posts
Processing order of importing files (2003)
I have the following code that gets a list of files to import. <pre>FName = Dir(importPath & "PO*.csv")
Do While FName <> ""
ImportData = True
FileList(i) = FName
'move to the next file in the list
FName = Dir
i = i + 1
TotFiles = i</pre>
Then that array is run through and the files are imported into my database.
Is it possible to control the order they are loaded to the array? I NEED to process the oldest file first.
Thanks!<font face="Comic Sans MS">Morgan Erickson</font face=comic>
<img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.
2008-05-16, 20:02 #2
- Join Date
- Mar 2002
- Thanked 16 Times in 16 Posts
Re: Processing order of importing files (2003)
Dir always loops through the files in alphabetic order. You cannot change that. You could use Application.FileSearch instead. It results in an array of filenames, so you don't have to create the array yourself. And you can also get the number of found files
Dim i As Integer
.LookIn = importPath
.Filename = "PO*.csv"
If .Execute(msoSortByLastModified, msoSortOrderAscending) > 0 Then
TotFiles = .FoundFiles.Count
For i = 1 To TotFiles
Note: the FoundFiles array contains the complete file names including the path, not just the file names.
Warning: FileSearch is not available in Office 2007 any more.