Thread: Path Not Found
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
MSP77079[_5_] MSP77079[_5_] is offline
external usenet poster
 
Posts: 1
Default Path Not Found


CheckPath: 'the next few lines of code will check to see if th
directory exists

With Application.FileSearch
.LookIn = ThisPath
If .LookIn < ThisPath Then
'if the directory does not exist, we will print
'an error message
MsgBox "Could not find the directory"
Else:
GoTo LookForFiles
End If
End With

LookForFiles:
'the next few lines of code will ensure that the file exists in tha
directory

With Application.FileSearch
.LookIn = ThisPath 'directory path
.Filename = "*.xls"
.SearchSubFolders = False

If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
If FileYouWant = .FoundFiles(i) Then GoTo StartWork
Next i
Else
MsgBox "There were no files found in " & ThisFilePath
vbCritical
GoTo EndOfMacro
End If
NumberOfFilesFound = .FoundFiles.Count
End Wit

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