ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   File Could not be Found (https://www.excelbanter.com/excel-programming/350038-file-could-not-found.html)

Vishal[_3_]

File Could not be Found
 
Hi

I want to open a file using my Macro. But I dont want to give the
absolute path.
I've the macro in FileA.xls and I want to open FileB.xls and both the
files are in the same directory.

I am using Workbooks.open filename:= "FileB.xls"

But it gives me the error - File FileB.xls could not be found.
If I use the absolute path in the above statement, everything works
fine.

Any suggestions ?

Thanks
Vishal


Norman Jones

File Could not be Found
 
Hi Vishal,

Try:

'=============
Public Sub Tester()
Dim sPath As String

sPath = ThisWorkbook.Path
Workbooks.Open Filename:=sPath & "\" & "FileB.xls"

End Sub
'<<=============

---
Regards,
Norman



"Vishal" wrote in message
oups.com...
Hi

I want to open a file using my Macro. But I dont want to give the
absolute path.
I've the macro in FileA.xls and I want to open FileB.xls and both the
files are in the same directory.

I am using Workbooks.open filename:= "FileB.xls"

But it gives me the error - File FileB.xls could not be found.
If I use the absolute path in the above statement, everything works
fine.

Any suggestions ?

Thanks
Vishal





All times are GMT +1. The time now is 10:22 PM.

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