Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Strange problem with filesearch...help


Hi,

I have found a very strange and dificullt problem to overcome in th
filesearch.

When a user tries to create a new workbook file in my program, it wil
first check to see if the file already exists in the working folder
for the application, and if it does, then it pops up a message sayin
that it already exists so they cant create it.

Ok, I thought it was perfect, until they discovered that if the have
workbook named for example, week49-555EWO.xls, and they try to create
file named week49-555.xls, the file search says that the file nam
already exists!! So obviously Filesearch is using some sort of strin
search that looks for any characters that exist within that fil
name...for instance, if I try to create a new file calle
week49-55.xls, it will also say it exists!! or any combination up t
the last character of the name, week49-555EWO. It is ver
frusterating, and I can't think of how to get around it . I have, o
course, set the .MatchTextExactly to true, but that doesn't seem t
make any difference.

Here is my code


Set objFileSearch = Application.FileSearch
With objFileSearch
.NewSearch
.LookIn = startSearchDirectory
.SearchSubFolders = True
.filename = holdThisFileName
.MatchTextExactly = True
If .Execute 0 Then
holdName = .filename
MsgBox "There is already a file named " & holdThisFileName
", in the system. If you are unsure how to proceed then please spea
to your supervisor.", vbOKOnly, "File Conflict..."
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Exit Sub
End If
End With


Any ideas, anyone?

Thanks,

Ree

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Strange problem with filesearch...help


The line

holdName = .filename

is not supposed to be there...was some wrong code

Thx


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Strange problem with filesearch...help

Set objFileSearch = Application.FileSearch
With objFileSearch
.NewSearch
.LookIn = startSearchDirectory
.SearchSubFolders = True
.filename = holdThisFileName
'MatchTextExactly = True
If .Execute 0 Then
for i = 1 to .foundfiles.count
if Ucase(holdThisFileName) = Ucase(.filename(i)) then

MsgBox "There is already a file named " & holdThisFileName &
", in the system. If you are unsure how to proceed then please speak
to your supervisor.", vbOKOnly, "File Conflict..."
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Exit Sub
end if
Next
End If
End With

--
Regards,
Tom Ogilvy


reesmacleod wrote in message
...

The line

holdName = .filename

is not supposed to be there...was some wrong code

Thx


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Strange problem with filesearch...help


Thanks again Tom. You are Invaluable.

I came up with a similar solution not too long after, and as I think on
it I am surprised about that behaviour. Is it a bug? Shouldn't
..MatchTextExactly only find entire string matches and not partial
matches?

Rees


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Strange problem with filesearch...help

MatchTextExactly refers to doing a search for text contained in a file, not
the name.

--
Regards,
Tom Ogilvy


"reesmacleod" wrote in message
...

Thanks again Tom. You are Invaluable.

I came up with a similar solution not too long after, and as I think on
it I am surprised about that behaviour. Is it a bug? Shouldn't
MatchTextExactly only find entire string matches and not partial
matches?

Rees


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements


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
Strange Problem Perry Excel Discussion (Misc queries) 7 April 12th 06 09:52 PM
Strange Problem... Sujesh Excel Discussion (Misc queries) 6 December 30th 05 02:56 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 04:58 PM.

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"