ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Determine if a File Exists (https://www.excelbanter.com/excel-discussion-misc-queries/117887-determine-if-file-exists.html)

Connie

Determine if a File Exists
 
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


Bob Phillips

Determine if a File Exists
 
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)

"Connie" wrote in message
ups.com...
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





All times are GMT +1. The time now is 01:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com