ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check a file in a directory (https://www.excelbanter.com/excel-programming/298730-check-file-directory.html)

Rich Cooper

Check a file in a directory
 
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.



Township of East Hanover

Check a file in a directory
 
Path = "driverletterhe\directoryhere\filenamehere"
If Len(Dir(Path)) = 0 Then


"Rich Cooper" wrote in message
...
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.





Chip Pearson

Check a file in a directory
 
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



"Rich Cooper" wrote in message
...
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.






All times are GMT +1. The time now is 08:53 AM.

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