Testing for filke in directory
sPath = "E:\LE\LE " & XlMonth2 & " 05\" & "29382_" _
& XlMonth2 & "_CIS_Ph1&2 Roll Up .xls"
if dir(spath) < "" Then
xlApp.Workbooks.Open sPath, 0, ReadOnly = True
xlApp.ActiveWorkbook.Windows(1).Visible = False
else
msgbox sPath & vbNewLine & _
"was not found"
end if
--
Regards,
Tom Ogilvy
"Helen" wrote in message
...
I have read through some of the posts but cannot find an answer to the
question of - - How do you test for the existance of a file in a
directory.
I can create and navigate to directories based upon month of the year as
per
my example code:
sPath = "E:\LE\LE " & XlMonth2 & " 05\" & "29382_" & XlMonth2 &
"_CIS_Ph1&2 Roll Up .xls"
xlApp.Workbooks.Open sPath ' & Format(Date, "yyyymmdd.xls")
xlApp.Workbooks.Open (sPath), 0, ReadOnly = True
xlApp.ActiveWorkbook.Windows(1).Visible = False
But how do I test if the file is there before trying to open it in case
the
file has not yet been deposited by the accounting departmnet yet?
|