Check a file in a directory

R

Rich Cooper

I am trying to have excel file check to see if another excel files is a
directory. If it is i want it to call it and run that file. But if that
file is not i want it to continue on. Any help on how to do this would be
great.
 
T

Township of East Hanover

Path = "driverletterhere:\directoryhere\filenamehere"
If Len(Dir(Path)) = 0 Then
 
C

Chip Pearson

Rich,

Try something like

Dim FName As String
Dim WB As Workbook
FName = "C:\Test\Test.xls" '<<<< CHANGE FILE NAME
If Dir(FName)<>"" Then
' file exists
Set WB = Workbook.Open(FName)
Else
' file does not exist
End If

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Top