ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filesearch Runny Like a Wiped Dog Phenomenon (https://www.excelbanter.com/excel-programming/274353-re-filesearch-runny-like-wiped-dog-phenomenon.html)

Dick Kusleika

Filesearch Runny Like a Wiped Dog Phenomenon
 
Shawn

I've heard people complain about FileSearch in the past, but I don't recall
what specifically the problems were. Whatever it was, I decided then not to
use it and to use Dir or the FileSystemObject instead. There doesn't seem
to be anything that you're doing that you can't do with the Dir function.
You might consider using that instead.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Shawn K Haase" wrote in message
...
How-D!

I got Office XP Developer 2002 SP-2 and Windows XP.

I wrote a little form's based app in Excel that would take
all the filenames from a user choosen directory and dump
them into a worksheet. From there I would copy and paste
the filenames into an email (I manipulate/organize alot of
CAD files and send them off to vendors and I like to send
a filename listing for each email...).

My app worked perfectly up until a month or so ago. Now
it lags for a FEW minutes whenever the
application.filesearch.execute() method is run. Before,
the filenames would plop into the worksheet in a matter of
a second or two.

I can't recall me having run any updates though I can't
vouch for our Sys Admin doing the same after hours.

I have attached the code to this post for the heck of it.
I believe that there is nothing wrong with it since it
used to run flawlessly for ever.

I am curious to now if the FileSearch object uses a
Windows Dll or something to run properly. Maybe this Dll
needs replacing. Who knows???

I had the installation "repaired" today via the Office CDs
but this did not improve the situation...

Maybe it needs Indexing Services turned on or off. Who
Knows???

Any idears????

Thanx,

Shawn K Haase


Private Sub cmdExtractFilenames_Click()

' Will erase ALL content on active page
Cells.Select
Selection.ClearContents

sPath = Application.GetOpenFilename
LastSlashPos = InStrRev(sPath, "\")
sPath = Mid(sPath, 1, LastSlashPos)
Set oSht = ActiveWorkbook.ActiveSheet
nRow = 3
With Application.FileSearch
.NewSearch
.LookIn = sPath
.SearchSubFolders = False
.Filename = "*.*"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
End With
With Application.FileSearch
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
Filename = .FoundFiles(i)
Length = Len(Filename)
If frmGetInfo.optHideExtension.Value = True
Then
ExtensionPos = InStrRev(Filename, ".")
Filename = Mid(Filename, 1, ExtensionPos -
1)
End If
LastSlashPos = InStrRev(Filename, "\")
Filename = Mid(Filename, LastSlashPos + 1)
If frmGetInfo.chkUseFileNameFormat.Value =
True Then
Filename = "<Filename: " + Filename + ""
ElseIf frmGetInfo.chkBracketFilename.Value =
True Then
Filename = "<< " + Filename + ""
End If
oSht.Cells(nRow, 2).Value = Filename
nRow = nRow + 1
Next i
Else
MsgBox "There were no files found."
End If
End With


End Sub





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com