Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Counting backwards through the File System Object files collection

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Counting backwards through the File System Object files collection

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Counting backwards through the File System Object files collection

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Counting backwards through the File System Object files collection

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Counting backwards through the File System Object files collection

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA and File System Object [email protected] Excel Programming 3 September 7th 06 06:21 PM
File System Object Jason Zischke Excel Programming 3 August 30th 06 07:52 AM
How do I close a file system object? Steph Excel Programming 2 March 8th 06 04:09 AM
File System Object Neil Excel Programming 2 September 10th 03 05:01 PM


All times are GMT +1. The time now is 04:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"