Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Application.FileSearch on only one level of sub folders

I want to use Application.FileSearch to search for xls files in the second
level of a folder structure. I have many folders with the target xls files in
each folder. But then an 'archive' folder attached to the folder with more
xls files with the same name. Everytime it searches I end up with the main
file and the archive file.

Due to the number of folders, I need to use the .SearchSubFolders = True
property, but is there any way of telling it to only go down one level?

Level 1
|__ Level 2...
| |__ ****.xls - WANT TO SEARCH THESE
| |__ Level 3...
| |__ ****.xls - NOT THESE
|__ Level 2...
|__ Level 2...

The extract of code I have is:

With Application.FileSearch
.NewSearch
.LookIn = "c:\temp\amp test"
.Filename = "933_????.xls"
.SearchSubFolders = True
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then ......................blah blah blah

Any help on this would be great, thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Application.FileSearch on only one level of sub folders

No, but you can easily put in an if statement when working with the results
and only process those found at the second level.

--
Regards,
Tom Ogilvy

"Crustysquirrel" wrote in message
...
I want to use Application.FileSearch to search for xls files in the second
level of a folder structure. I have many folders with the target xls files

in
each folder. But then an 'archive' folder attached to the folder with more
xls files with the same name. Everytime it searches I end up with the main
file and the archive file.

Due to the number of folders, I need to use the .SearchSubFolders = True
property, but is there any way of telling it to only go down one level?

Level 1
|__ Level 2...
| |__ ****.xls - WANT TO SEARCH THESE
| |__ Level 3...
| |__ ****.xls - NOT THESE
|__ Level 2...
|__ Level 2...

The extract of code I have is:

With Application.FileSearch
.NewSearch
.LookIn = "c:\temp\amp test"
.Filename = "933_????.xls"
.SearchSubFolders = True
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then ......................blah blah blah

Any help on this would be great, thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Application.FileSearch on only one level of sub folders

That is great, thanks for your help Tom. I will have to see how the IF is
going to fit in with my code.

"Tom Ogilvy" wrote:

No, but you can easily put in an if statement when working with the results
and only process those found at the second level.

--
Regards,
Tom Ogilvy

"Crustysquirrel" wrote in message
...
I want to use Application.FileSearch to search for xls files in the second
level of a folder structure. I have many folders with the target xls files

in
each folder. But then an 'archive' folder attached to the folder with more
xls files with the same name. Everytime it searches I end up with the main
file and the archive file.

Due to the number of folders, I need to use the .SearchSubFolders = True
property, but is there any way of telling it to only go down one level?

Level 1
|__ Level 2...
| |__ ****.xls - WANT TO SEARCH THESE
| |__ Level 3...
| |__ ****.xls - NOT THESE
|__ Level 2...
|__ Level 2...

The extract of code I have is:

With Application.FileSearch
.NewSearch
.LookIn = "c:\temp\amp test"
.Filename = "933_????.xls"
.SearchSubFolders = True
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then ......................blah blah blah

Any help on this would be great, thanks.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Application.FileSearch on only one level of sub folders

Crusty,
There is an earlier thread "Macro won't run from d: drive, but works on c:
drive", from 29/07/05 that highlights the inadequanies of .FileSearch.
A Dir() for all the directories, then Dir() each directory should be easy
enough.

NickHK

"Crustysquirrel" wrote in message
...
That is great, thanks for your help Tom. I will have to see how the IF is
going to fit in with my code.

"Tom Ogilvy" wrote:

No, but you can easily put in an if statement when working with the

results
and only process those found at the second level.

--
Regards,
Tom Ogilvy

"Crustysquirrel" wrote in

message
...
I want to use Application.FileSearch to search for xls files in the

second
level of a folder structure. I have many folders with the target xls

files
in
each folder. But then an 'archive' folder attached to the folder with

more
xls files with the same name. Everytime it searches I end up with the

main
file and the archive file.

Due to the number of folders, I need to use the .SearchSubFolders =

True
property, but is there any way of telling it to only go down one

level?

Level 1
|__ Level 2...
| |__ ****.xls - WANT TO SEARCH THESE
| |__ Level 3...
| |__ ****.xls - NOT THESE
|__ Level 2...
|__ Level 2...

The extract of code I have is:

With Application.FileSearch
.NewSearch
.LookIn = "c:\temp\amp test"
.Filename = "933_????.xls"
.SearchSubFolders = True
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then ......................blah blah blah

Any help on this would be great, thanks.






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 Cleberton(Brazilian) Excel Discussion (Misc queries) 2 October 26th 09 01:21 PM
Help with Application.FileSearch method Roy Harrill Excel Programming 4 August 1st 05 12:56 AM
Application.FileSearch crashed Excel in Windows 2K Ken Loomis Excel Programming 0 July 14th 05 01:04 AM
Application.FileSearch is not working?? alondon Excel Programming 5 January 18th 05 03:12 AM
VBA Application.FileSearch Roger Frye Excel Programming 0 March 5th 04 04:07 AM


All times are GMT +1. The time now is 02:26 AM.

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"