Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problem with Filesearch | Excel Programming | |||
Strange problem with filesearch...help | Excel Programming | |||
FileSearch Problem | Excel Programming | |||
FileSearch Problem | Excel Programming | |||
FileSearch Problem | Excel Programming |