R
reesmacleod
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
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