Sequence of subfoldres (1 Viewer)

sja13

Professional Idiot
Local time
Today, 13:50
Joined
May 3, 2017
Messages
63
I have a "main" folder, in which there are subfolders.

I have VBA to get the name of every subfolder present in the main folder, but I wondered if there is a way I can get the names of the subfolders returned in "Date Created" sequence, instead of alphabetical sequence?

I know I can write VBA to recover the folders' creation dates into an array, then sort the array, but I wondered if there was any way to modify an attribute in the main folder (similar to clicking on Date Created in Windows Explorer) to achieve my aim?

I've tried using Watch to examine the main folder's attributes when Dim'd as Folder or Dim'd as Object, but can't find anything which looks like it could be modified to achieve my aim.

Any ideas?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 13:50
Joined
Feb 19, 2013
Messages
16,607
I don't think there is any specific order that files/subfolders are returned. If they are coming back in alphabetical order that may be a coincidence.

adjusting the explorer view by sorting is specific to explorer and again, I don't think would have any impact on how files/folders are returned.

Think you will have to go the array route (or populate an adodb recordset)
 

ashleedawg

"Here for a good time"
Local time
Today, 05:50
Joined
Jun 22, 2017
Messages
154

jdraw

Super Moderator
Staff member
Local time
Today, 08:50
Joined
Jan 23, 2006
Messages
15,379
It depends on what you really need. You could consider the DOS Dir command with parameters


You can direct the output to a file that you could import to Access

eg
DIR /s/b *.jpg >c:\users\bob\documents\BobFile.txt
 

sja13

Professional Idiot
Local time
Today, 13:50
Joined
May 3, 2017
Messages
63
Thanks to all for the thoughtful replies.

As it happens I already have a User written sort function in VBA, but it seemed a bit extreme to deploy it.

I often find I've spent hours coding and testing VBA, only for someone to say "Why didn't you just use the 'Wibble' function?".

Looks like for once the investment in coding paid off!
 

Users who are viewing this thread

Top Bottom