Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default FileSearch Problem

Does anyone know the rules for application file search, I have a curious
result from the following search in my application. If the string
'audit.csv' appears in any file in the chosen path I get True as file
exists. Despite not including wild cards in the search string filename.

My test reveal the following:
1. audit.csv =True
2. xxaudit.csv =True
3. auditxx.csv =False
I would have expected option 2 to return False, is there something I should
do in addition to fix this ?


' search for the audit.csv file if it exists
Dim vFileExists As Boolean
Application.FileSearch.LookIn = vPath
Application.FileSearch.Filename = "audit.csv"
If Application.FileSearch.Execute 0 Then
vFileExists = True
Else
vFileExists = False
End If




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default FileSearch Problem

Hi All found the problem - I need to apply the following property to the
search.

..MatchTextExactly = True

Cheers

"Nigel" wrote in message
...
Does anyone know the rules for application file search, I have a curious
result from the following search in my application. If the string
'audit.csv' appears in any file in the chosen path I get True as file
exists. Despite not including wild cards in the search string filename.

My test reveal the following:
1. audit.csv =True
2. xxaudit.csv =True
3. auditxx.csv =False
I would have expected option 2 to return False, is there something I

should
do in addition to fix this ?


' search for the audit.csv file if it exists
Dim vFileExists As Boolean
Application.FileSearch.LookIn = vPath
Application.FileSearch.Filename = "audit.csv"
If Application.FileSearch.Execute 0 Then
vFileExists = True
Else
vFileExists = False
End If




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet

News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000

Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption

=---




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default FileSearch Problem


"Nigel" wrote in message
...
Does anyone know the rules for application file search, I have a curious
result from the following search in my application. If the string
'audit.csv' appears in any file in the chosen path I get True as file
exists. Despite not including wild cards in the search string filename.

My test reveal the following:
1. audit.csv =True
2. xxaudit.csv =True
3. auditxx.csv =False
I would have expected option 2 to return False, is there something I

should
do in addition to fix this ?


' search for the audit.csv file if it exists
Dim vFileExists As Boolean
Application.FileSearch.LookIn = vPath
Application.FileSearch.Filename = "audit.csv"
If Application.FileSearch.Execute 0 Then
vFileExists = True
Else
vFileExists = False
End If




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet

News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000

Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption

=---


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default FileSearch Problem

try this

Sub findonefile()
With Application.FileSearch
.NewSearch
.LookIn = "C:\mydirectory"
.Filename = "audit.csv"
ahah = .Execute()
End With
MsgBox ahah 'got 1 means found 0=not found
End Sub

"Nigel" wrote in message
...
Does anyone know the rules for application file search, I have a curious
result from the following search in my application. If the string
'audit.csv' appears in any file in the chosen path I get True as file
exists. Despite not including wild cards in the search string filename.

My test reveal the following:
1. audit.csv =True
2. xxaudit.csv =True
3. auditxx.csv =False
I would have expected option 2 to return False, is there something I

should
do in addition to fix this ?


' search for the audit.csv file if it exists
Dim vFileExists As Boolean
Application.FileSearch.LookIn = vPath
Application.FileSearch.Filename = "audit.csv"
If Application.FileSearch.Execute 0 Then
vFileExists = True
Else
vFileExists = False
End If




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet

News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000

Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption

=---


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default FileSearch Problem

Nigel,

I don't know how to limit FileSearch's enthousiasm..
Why it wont except normal wildcards? Beyond me!

...except to filter the foundfile collection post execute.

I've wrapped it into a function like this:
NOT thoroughly tested but it seems to work
(note that it's Excel2000 and newer only)



Sub Test()
Dim v
v = FindIt("c:\dummy*.csv")
End Sub

Function FindIt(Search$)
Dim res() As String
Dim i As Integer

ReDim res(1 To 1)
With Application.FileSearch
.NewSearch
.LookIn = Left(Search, InStrRev(Search, "\"))
.Filename = Mid(Search, InStrRev(Search, "\") + 1)
.SearchSubFolders = False
.Execute
Search = LCase("*\" & .Filename)
For i = 1 To .FoundFiles.Count
If LCase(.FoundFiles(i)) Like Search Then
ReDim Preserve res(1 To UBound(res) + 1)
res(UBound(res) - 1) = .FoundFiles(i)
End If
Next
End With

If UBound(res) 1 Then
ReDim Preserve res(1 To UBound(res) - 1)
FindIt = res
End If
End Function




keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Nigel" wrote:

Does anyone know the rules for application file search, I have a
curious result from the following search in my application. If the
string 'audit.csv' appears in any file in the chosen path I get True
as file exists. Despite not including wild cards in the search string
filename.

My test reveal the following:
1. audit.csv =True
2. xxaudit.csv =True
3. auditxx.csv =False
I would have expected option 2 to return False, is there something I
should do in addition to fix this ?


' search for the audit.csv file if it exists
Dim vFileExists As Boolean
Application.FileSearch.LookIn = vPath
Application.FileSearch.Filename = "audit.csv"
If Application.FileSearch.Execute 0 Then
vFileExists = True
Else
vFileExists = False
End If




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet
News==---- http://www.newsfeed.com The #1 Newsgroup Service in the
World! 100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers
- Total Privacy via Encryption =---


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
FileSearch in a combo box michaelberrier Excel Discussion (Misc queries) 0 June 16th 06 12:21 AM
FileSearch dislikes Zip-files Hub van de Laar Excel Programming 4 September 1st 03 08:50 PM
FileSearch Code Pedro[_4_] Excel Programming 1 August 6th 03 02:27 PM
FileSearch Problem Bin[_2_] Excel Programming 6 August 2nd 03 02:04 PM


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