Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel 2007 / application.filesearch no longer works

Hello,

In 2007, the application.filesearch no longer works for my vba scripts, I'm
trying to find a work around, I figured out how to loop through files in a
given folder, but need help creating one more nested loop so that I can loop
through folders, then loop through the files in each folder, here is a sample
of what I have so far, any help would be greatly appreciated.

Dim sFolder As String
Dim Folder As Object
Dim file As Object
Dim fso As Object

Set fso = CreateObject("Scripting.FileSystemObject")
sFolder = "C:\temp"
'***I have multiple folders in temp, need to find code to loop thru each......
If sFolder < "" Then
Set Folder = fso.GetFolder(sFolder)
For Each file In Folder.Files
MyFile = file
'**** do stuff to each file
Next file
End If


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Excel 2007 / application.filesearch no longer works

See
http://www.rondebruin.nl/fso.htm

See also the Merge add-in
http://www.rondebruin.nl/merge.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Pete Ross" wrote in message ...
Hello,

In 2007, the application.filesearch no longer works for my vba scripts, I'm
trying to find a work around, I figured out how to loop through files in a
given folder, but need help creating one more nested loop so that I can loop
through folders, then loop through the files in each folder, here is a sample
of what I have so far, any help would be greatly appreciated.

Dim sFolder As String
Dim Folder As Object
Dim file As Object
Dim fso As Object

Set fso = CreateObject("Scripting.FileSystemObject")
sFolder = "C:\temp"
'***I have multiple folders in temp, need to find code to loop thru each......
If sFolder < "" Then
Set Folder = fso.GetFolder(sFolder)
For Each file In Folder.Files
MyFile = file
'**** do stuff to each file
Next file
End If


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
application.filesearch error in excel 2007 Ramesh Excel Programming 3 February 11th 08 11:54 AM
Application.FileSearch in 2007 Amery Excel Programming 2 December 13th 07 10:49 PM
replacement for Application.FileSearch in 2007 SteveDB1 Excel Programming 1 July 11th 07 06:28 PM
Code No Longer Works in 2007 Chaplain Doug Excel Programming 2 February 6th 07 06:12 PM
??? application.screenupdating no longer works! Why??? CraTaw Excel Programming 4 September 29th 06 04:37 PM


All times are GMT +1. The time now is 08:25 PM.

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

About Us

"It's about Microsoft Excel"