File Checking

  • Thread starter Thread starter Donald Lloyd
  • Start date Start date
D

Donald Lloyd

Hi,

My thanks to Chip Pearson and Bob Phillips for their informed replies to my
recent query re worksheet tabs - they made life a lot easier.

Another, if you don't mind.

I wish to check the current directory for the existence of an user entered
filename.
What's the simplest way of doing thias - I would rather not invoke the
SaveAs dialog box.

regards,
Don Lloyd

--
 
Donald,

Use the Dir function to determine if the file exists. E.g.,


Dim FName As String
FName = InputBox("Enter a file name")
If FName <> "" Then
If Dir(FName) <> "" Then
MsgBox "File Exists"
Else
MsgBox "File does not exist"
End If
Else
MsgBox "You didn't enter a file name"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
Thank you chip.

Excellent - almost a one-liner!

Thanks and regards,
Don

--

Chip Pearson said:
Donald,

Use the Dir function to determine if the file exists. E.g.,


Dim FName As String
FName = InputBox("Enter a file name")
If FName <> "" Then
If Dir(FName) <> "" Then
MsgBox "File Exists"
Else
MsgBox "File does not exist"
End If
Else
MsgBox "You didn't enter a file name"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
Back
Top