![]() |
Open file in VBA
Hello,
When I walk through the following statement I get a run time error 1004 that says that the particular file couls not be found. I used the following statement: sFilename = Dir("H:\Risk_Management\Special_Review\Upload_file s\*.xls") Workbooks.Open Filename:=sFilename Do I forgot something? Thanks for your assistance!! Rgds, Robert |
Open file in VBA
Hi Robert,
dim sFilename as string sFilename = Dir("H:\Risk_Management\Special_Review\Upload_file s\*.xls") if len(sfilename)<0 then Workbooks.Open Filename:=sFilename else 'no file path returned from dir("H:\Risk_Management\Special_Review\Upload_file s\*.xls") end if Regads, Ivan |
Open file in VBA
Another possibility:
Dir doesn't return the path in sFileName, so Dim sPath as String, sFileName as String sPath = "H:\Risk_Management\Special_Review\Upload_file s\" sFileName = Dir(sPath & "*.xls") if sFileName < "" then workbooks.Open Filename:=sPath & sFileName Else msgbox "No excel workbooks" End if -- Regards, Tom Ogilvy *.xls") Workbooks.Open Filename:=sFilename "Robert" wrote: Hello, When I walk through the following statement I get a run time error 1004 that says that the particular file couls not be found. I used the following statement: sFilename = Dir("H:\Risk_Management\Special_Review\Upload_file s\*.xls") Workbooks.Open Filename:=sFilename Do I forgot something? Thanks for your assistance!! Rgds, Robert |
All times are GMT +1. The time now is 05:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com