?
Solved

how to sort filenames

Posted on 2003-02-20
1
Medium Priority
?
139 Views
Last Modified: 2010-04-07
i want to sort the files in a folder by date & time. any way?
0
Comment
Question by:ackid32
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
rdrunner earned 150 total points
ID: 7986063
There is a great tool for all yout sorting needs...

Its called a Recordset... Just fill in all data about the files you have and sort by the fields you want by just telling which fields you want...

This example only cares about name & Date

'snipp

Dim oRS As New Recordset
oRS.Fields.Append "name", adVarChar, 255
oRS.Fields.Append "date", adDate

Set oFolder = ofso.GetFolder("c:\winnt")
oRS.Open
For Each oFile In oFolder.Files
        oRS.AddNew
        oRS("name").Value = oFile.Name
        oRS("date").Value = oFile.DateLastModified
Next
oRS.Sort = "date asc"
oRS.MoveFirst

While Not oRS.EOF
    Debug.Print oRS("name"), oRS("date")
    oRS.MoveNext
Wend

'snapp

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question