Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a number of txt files in a directory and wants to read them b EXCEL. The names of the files are defined by a formula. However sometimes the formula create a filename which not reall exists. So before I open the file in EXCEL I want to check or that fil exists. To do that I used the code below: Sub test() With Application.FileSearch .NewSearch .LookIn = (Interaction.Environ$("userprofile") & "\M Documents\Test files\") .SearchSubFolders = False .Filename = "up12_7.txt" .MatchTextExactly = True .FileType = msoFileTypeAllFiles If .Execute() 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." For i = 1 To .FoundFiles.Count MsgBox .FoundFiles(i) Next i Else MsgBox "There were no files found." End If End With End Sub The problem is that in this case the MsgBox will report that 2 file exist, "up12_7.txt" and "up12_70.txt", inspite the fact that .MatchTextExactly = True is used. How can I change this, so I'm sure it will only look to the fil "up12_7.txt"? Thanks for you help by forehand. Best regards, Gerri -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Check for a tab if it is exist | Excel Discussion (Misc queries) | |||
CSV file give different result when open in excel 2003 SP2 & Sp3 | Excel Discussion (Misc queries) | |||
excel result return wrong calcuation result | Excel Worksheet Functions | |||
excel result return wrong calcuation result | Excel Worksheet Functions | |||
excel result return wrong calcuation result | Excel Worksheet Functions |