LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Another FileSearch Problem

I didn't know whether to include this with my other post, because it came up in the same program, but is really a different issue.

When I use the following code in Excel 97 (regardless of operating system) (to determine whether a file with no extension - strLocFile - from one folder has a matching file with an .xls extension in another and, if so, count it):

With Application.FileSearch
.NewSearch
.FileName = strLocFile & ".xls"
.LookIn = strFolderName
.MatchTextExactly = True 'This doesn't work as required
.Execute
y = .FoundFiles.Count
End With

where strLocFile is a numeric file name (eg 1234), the procedure will consider the file 12345.xls to be a match, even though I've used .MatchTextExactly.

I wrote the following workaround, which is placed immediately before the End With:

'This replaces MatchTextExactly property
' by testing for exact string match
If y 0 Then
For i = 1 To y
If LCase(Trim(strLocFile & ".xls")) = _
ParentFolder(LCase(Trim(.FoundFiles(1)))) Then
z = z + 1
Exit For
End If
Next i
End If

(ParentFolder is a function I wrote to get the last folder or file in a path; I'm now aware of another, simpler method of getting the file name only, but haven't had a chance to test/apply it yet.)

Am I misinterpreting the use of .MatchTextExactly, or is it a bug? Does anyone have a tidier workaround?

BTW, does anyone else have a problem with the scroll bar to the right of the message window when posting these messages? Neither the arrow keys nor the grey scroll bar areas work (on this PC, at least) as they do in a normal windows program, so I can only use the scroll button or the keyboard arrows; however, I haven't posted in this forum before, so perhaps it will be OK on my own PC!

Thanks and regards
--
Alison
 
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
Problem with Filesearch MikeM[_5_] Excel Programming 0 March 2nd 04 09:36 PM
Strange problem with filesearch...help reesmacleod[_8_] Excel Programming 4 December 8th 03 06:29 PM
FileSearch Problem Jarek[_3_] Excel Programming 3 November 27th 03 02:06 PM
FileSearch Problem Nigel[_4_] Excel Programming 4 October 11th 03 03:43 PM
FileSearch Problem Bin[_2_] Excel Programming 6 August 2nd 03 02:04 PM


All times are GMT +1. The time now is 09:05 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"