Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's the deal.
I'm attempting to move backwards through the fso files collection but getting an "invalid procedure call" error. Here's the code I'm struggling with: Dim objFso As FileSystemObject Dim objFolder As Folder Dim objFile As File Dim z As Long Set dTPlusOneFiles = New Dictionary 'Count backwards through the files collection to get the four most recently created files For z = objFolder.Files.Count To 1 Step -1 Set objFile = objFolder.Files(z) dTPlusOneFiles.Add objFile.Name, objFile.DateCreated Next z Strangely the error message occurs at this point: "Set objFile = objFolder.Files(z)" Any assistance will be gratefully appreciated. Rob |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rob,
You will have to use a For | Each construct to iterate the Files collection and fill the Dictionary object. Once that is complete, you could add the Dictionary "Items" or "Keys" array to a worksheet and sort it. -- Jim Cone Portland, Oregon USA "signon77" wrote in message Here's the deal. I'm attempting to move backwards through the fso files collection but getting an "invalid procedure call" error. Here's the code I'm struggling with: Dim objFso As FileSystemObject Dim objFolder As Folder Dim objFile As File Dim z As Long Set dTPlusOneFiles = New Dictionary 'Count backwards through the files collection to get the four most recently created files For z = objFolder.Files.Count To 1 Step -1 Set objFile = objFolder.Files(z) dTPlusOneFiles.Add objFile.Name, objFile.DateCreated Next z Strangely the error message occurs at this point: "Set objFile = objFolder.Files(z)" Any assistance will be gratefully appreciated. Rob |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Have you tried
objFolder.Files.Item(z) Tim "signon77" wrote in message ... Here's the deal. I'm attempting to move backwards through the fso files collection but getting an "invalid procedure call" error. Here's the code I'm struggling with: Dim objFso As FileSystemObject Dim objFolder As Folder Dim objFile As File Dim z As Long Set dTPlusOneFiles = New Dictionary 'Count backwards through the files collection to get the four most recently created files For z = objFolder.Files.Count To 1 Step -1 Set objFile = objFolder.Files(z) dTPlusOneFiles.Add objFile.Name, objFile.DateCreated Next z Strangely the error message occurs at this point: "Set objFile = objFolder.Files(z)" Any assistance will be gratefully appreciated. Rob |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tim,
I did. Did you? <g -- Jim Cone Portland, Oregon USA "Tim Williams" wrote in message Have you tried objFolder.Files.Item(z) Tim |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Nope!
Tim "Jim Cone" wrote in message ... Tim, I did. Did you? <g -- Jim Cone Portland, Oregon USA "Tim Williams" wrote in message Have you tried objFolder.Files.Item(z) Tim |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA and File System Object | Excel Programming | |||
File System Object | Excel Programming | |||
How do I close a file system object? | Excel Programming | |||
File System Object | Excel Programming |