Thread
:
IF File Exists
View Single Post
#
1
Posted to microsoft.public.excel.programming
Lenny_821[_8_]
external usenet poster
Posts: 1
IF File Exists
Hi
Try something like this (info excel help);
Set fs = Application.FileSearch
With fs
.LookIn = "C:\My Documents"
.SearchSubFolders = True
.FileName = MyFile
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
Lenny
Wrote:
I am writing a macro and have run into 2 problems.
FIRST: How can I validate that a a File "MyFile"
exists, and if the file does NOT exist, then exit the
procedure.
SECOND: if the File exists and is empty I want
advise the user
--
Lenny_82
-----------------------------------------------------------------------
Lenny_821's Profile:
http://www.excelforum.com/member.php...fo&userid=1517
View this thread:
http://www.excelforum.com/showthread.php?threadid=31943
Reply With Quote
Lenny_821[_8_]
View Public Profile
Find all posts by Lenny_821[_8_]