Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default limit the number of files filesearch looks through

Hey all,

I'm trying to use filesearch to look in a directory at certain files
and open them up. I'm getting success on my initial trial runs, but
when I go to looking in a folder across a Windows Network, it slows the
whole process down immensly. This folder can have over 1000 files, and
its just taking too long to get any good results. I really only want
to look at the past few files if possible. Is there a way to limit the
search to only the last 30 or so files that have been created? I've
tried to use the LastModified property and set it to
msoLastModifiedThisMonth, but it doesn't neccesarily make it any faster
of a process. Any thoughts?

Jeremy Heersink

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default limit the number of files filesearch looks through

Hi Jeremy,

How long does it take? Is the folder slow when you open in it via Windows
Explorer? If the network share goes over a slow pipe or is located on an
overutilized server, there's probably not much you can do.

Does using the FileSystemObject work any faster for you? Try the code below
(replace path as needed and set a reference to "Microsoft Scripting Runtime"
library via Tools | References.

Sub test()
Dim fso As Scripting.FileSystemObject
Dim fol As Scripting.Folder
Dim fil As Scripting.File

Set fso = New Scripting.FileSystemObject

Set fol = fso.GetFolder("<<your path here")

Debug.Print "Count: " & fol.Files.Count

For Each fil In fol.Files
If fil.DateLastModified DateSerial(2006, 7, 1) Then
Debug.Print fil.Name
End If
Next fil

Set fol = Nothing
Set fso = Nothing
End Sub

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]

wrote:
I'm trying to use filesearch to look in a directory at certain files
and open them up. I'm getting success on my initial trial runs, but
when I go to looking in a folder across a Windows Network, it slows
the whole process down immensly. This folder can have over 1000
files, and its just taking too long to get any good results. I
really only want to look at the past few files if possible. Is there
a way to limit the search to only the last 30 or so files that have
been created? I've tried to use the LastModified property and set it
to msoLastModifiedThisMonth, but it doesn't neccesarily make it any
faster of a process. Any thoughts?

Jeremy Heersink



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default limit the number of files filesearch looks through

I just tried using the FileSystemObject, and it is much faster in my
testing. Thanks so much. I guess its time for a real world test now.
Thanks for your help.

Jeremy Heersink

Jake Marx wrote:
Hi Jeremy,

How long does it take? Is the folder slow when you open in it via Windows
Explorer? If the network share goes over a slow pipe or is located on an
overutilized server, there's probably not much you can do.

Does using the FileSystemObject work any faster for you? Try the code below
(replace path as needed and set a reference to "Microsoft Scripting Runtime"
library via Tools | References.

Sub test()
Dim fso As Scripting.FileSystemObject
Dim fol As Scripting.Folder
Dim fil As Scripting.File

Set fso = New Scripting.FileSystemObject

Set fol = fso.GetFolder("<<your path here")

Debug.Print "Count: " & fol.Files.Count

For Each fil In fol.Files
If fil.DateLastModified DateSerial(2006, 7, 1) Then
Debug.Print fil.Name
End If
Next fil

Set fol = Nothing
Set fso = Nothing
End Sub

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]

wrote:
I'm trying to use filesearch to look in a directory at certain files
and open them up. I'm getting success on my initial trial runs, but
when I go to looking in a folder across a Windows Network, it slows
the whole process down immensly. This folder can have over 1000
files, and its just taking too long to get any good results. I
really only want to look at the past few files if possible. Is there
a way to limit the search to only the last 30 or so files that have
been created? I've tried to use the LastModified property and set it
to msoLastModifiedThisMonth, but it doesn't neccesarily make it any
faster of a process. Any thoughts?

Jeremy Heersink


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default limit the number of files filesearch looks through

Hi. Not sure if this is helpful, but in the FileSystemObject, one can
search by "msoSortByLastModified."

I just copied part of a code to see if anything here might be helpful.

This example quickly found the last saved file.

However, "msoSortByLastModified" still has a bug, even in Excel 2003. It
won't work on the first call. Therefore, your program has to make a token
simple search first. Then, you can use it to search as below...

With Application.FileSearch

....etc bug workaround...
.NewSearch
.LookIn = sFileDir
.FileName = sType
If .Execute(SortBy:=msoSortByLastModified, _
SortOrder:=msoSortOrderDescending) 0 Then
LastFileSaved = .FoundFiles(1)


Again, just thrown out to see if it's something you might want to try.
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"Jeremy Heersink" wrote in message
ups.com...
I just tried using the FileSystemObject, and it is much faster in my
testing. Thanks so much. I guess its time for a real world test now.
Thanks for your help.

Jeremy Heersink

Jake Marx wrote:
Hi Jeremy,

How long does it take? Is the folder slow when you open in it via
Windows
Explorer? If the network share goes over a slow pipe or is located on an
overutilized server, there's probably not much you can do.

Does using the FileSystemObject work any faster for you? Try the code
below
(replace path as needed and set a reference to "Microsoft Scripting
Runtime"
library via Tools | References.

Sub test()
Dim fso As Scripting.FileSystemObject
Dim fol As Scripting.Folder
Dim fil As Scripting.File

Set fso = New Scripting.FileSystemObject

Set fol = fso.GetFolder("<<your path here")

Debug.Print "Count: " & fol.Files.Count

For Each fil In fol.Files
If fil.DateLastModified DateSerial(2006, 7, 1) Then
Debug.Print fil.Name
End If
Next fil

Set fol = Nothing
Set fso = Nothing
End Sub

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]

wrote:
I'm trying to use filesearch to look in a directory at certain files
and open them up. I'm getting success on my initial trial runs, but
when I go to looking in a folder across a Windows Network, it slows
the whole process down immensly. This folder can have over 1000
files, and its just taking too long to get any good results. I
really only want to look at the past few files if possible. Is there
a way to limit the search to only the last 30 or so files that have
been created? I've tried to use the LastModified property and set it
to msoLastModifiedThisMonth, but it doesn't neccesarily make it any
faster of a process. Any thoughts?

Jeremy Heersink




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default limit the number of files filesearch looks through

You do know that any file search mechanism is not guaranteed to return files
in any specific order.
As such what to hope to learn from the "first few files" ?

If you really want to find the 30 files with the latest LastModified date,
you will of course have to scan all files in that folder in order to
determine which ARE the oldest.
If you do not do it in code, whatever "helper" you choose will still have do
it and only report the results to you.

If you are looking for speed, the API FindFirstFile/FindNextFile are your
best bet.

NickHK

wrote in message
oups.com...
Hey all,

I'm trying to use filesearch to look in a directory at certain files
and open them up. I'm getting success on my initial trial runs, but
when I go to looking in a folder across a Windows Network, it slows the
whole process down immensly. This folder can have over 1000 files, and
its just taking too long to get any good results. I really only want
to look at the past few files if possible. Is there a way to limit the
search to only the last 30 or so files that have been created? I've
tried to use the LastModified property and set it to
msoLastModifiedThisMonth, but it doesn't neccesarily make it any faster
of a process. Any thoughts?

Jeremy Heersink





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
Filesearch : .zip files not found ??? Benoît HUBERT Excel Programming 1 September 1st 04 06:28 PM
FileSearch dislikes Zip-files Hub van de Laar Excel Programming 4 September 1st 03 08:50 PM
FileSearch doesn't find zip files Hub van de Laar Excel Programming 3 September 1st 03 07:43 PM
FileSearch dislikes Zip-files Hub van de Laar Excel Programming 0 September 1st 03 06:53 PM
FileSearch dislikes Zip-files Hub van de Laar Excel Programming 0 September 1st 03 06:52 PM


All times are GMT +1. The time now is 10:20 PM.

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"