View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default 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