I'm trying to print documents in a directory, ordered by file name ascending. I have the script below to print out the documents, which works, but it's in a random order. Is there any way to sort the "files" collection based on name?
'Set the TargetFolder
TargetFolder = "C:\Temp\Hewitt\TestPrintFolder"
Set shellApplication = CreateObject("Shell.Application")
Set folder = shellApplication.Namespace(TargetFolder)
Set files = folder.Items
For Each file In files
file.InvokeVerbEx ("Print")
Next
The are many ways to get an odered list of the file(name)s in a directory. One uses the .NET ArrayList - like this:
If you can't harness .Net, you could
dir /o:n