Find a file position and continue to list following files
I don't know if this is faster but it's a different approach that might be
worth testing. It's a modification of a script I've used and I suspect it
may be more efficient to put the data on a sheet to sort when you're in
Excel but that may not be the case. Modify the line that sets the myPath
variable and give this a shot.
'--------------------------------------------
Sub AlphabetizeFileSet()
Const adVarChar = 200
Const MaxCharacters = 255
Dim myPath As String
Dim Fcnt As Integer
myPath = "C:\Scripts"
Set fso = CreateObject("Scripting.FileSystemObject")
Set targetFldr = fso.GetFolder(myPath)
Fcnt = targetFldr.Files.Count
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "FileName", adVarChar, MaxCharacters
DataList.Open
For Each myFile In targetFldr.Files
DataList.AddNew
DataList("FileName") = fso.GetFileName(myFile)
DataList.Update
Next myFile
DataList.Sort = "FileName"
' Do some stuff with sorted list of file names
DataList.AbsolutePosition = 1
MsgBox DataList.Fields.Item("FileName")
DataList.MoveNext
MsgBox DataList.Fields.Item("FileName")
DataList.AbsolutePosition = Fcnt
MsgBox DataList.Fields.Item("FileName")
Set fso = Nothing
Set DataList = Nothing
End Sub
'--------------------------------------------
Steve Yandl
"KT1972" wrote in message
...
Hi,
I can list all of the files in a folder. However I need to point a
specific
file in the folder and list following 50 files by every click a command
button.
# of files in the folder more than 10.000. I have taken all the file names
to an array and sorted the array. But It takes too long time because
folder
is dynamic (new files are added and deleted) and I must update the array
each
time.
Could you help me to find more efficient way to do it?
Thanks.
|