Determine if a File Exists

  • Thread starter Thread starter Connie
  • Start date Start date
C

Connie

I am using the following code to open a file:

EmployeeListFileName = PathName + "\hourly employees.csv"
Set wb = Workbooks.Open(EmployeeListFileName)

The user is entered to enter the PathName. I would like to return a
message if the file is not found in the specified directory. How do I
test whether the file is found?

Any help would be appreciated. Thanks!

Connie
 
EmployeeListFileName = PathName + "\hourly employees.csv"
On Error Resume Nexzt
Set wb = Workbooks.Open(EmployeeListFileName)
On Error Goto 0
If wb Is Nothing Then
Msgbox "File not found"
End If


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top