ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Local Directory File Access (https://www.excelbanter.com/excel-programming/357705-local-directory-file-access.html)

Alejandro[_4_]

Local Directory File Access
 
Hello all,

I am trying to get a macro to open a file in the same directory as the xl
file being launched. The code I am using is:
Workbooks.Open Filename:="DB-Data.xls"

For some reason it doesn't want to find it [although the help file says that
it should]. If I give it a full path, it has no problem. Is it possible to
do this? My goal is to get these workbooks available on CD for people to
work at home.

Thanks,
-=Alejandro



Jim Thomlinson

Local Directory File Access
 
Thisworkbook.path

will give you the path to the workbook running the code...
--
HTH...

Jim Thomlinson


"Alejandro" wrote:

Hello all,

I am trying to get a macro to open a file in the same directory as the xl
file being launched. The code I am using is:
Workbooks.Open Filename:="DB-Data.xls"

For some reason it doesn't want to find it [although the help file says that
it should]. If I give it a full path, it has no problem. Is it possible to
do this? My goal is to get these workbooks available on CD for people to
work at home.

Thanks,
-=Alejandro




Alejandro[_4_]

Local Directory File Access
 
Jim,

Thanks for the suggestion! That helped a lot. It works now, with the
addition of a '\' in front of the file name in the code, as such:
Workbooks.Open Filename:=(ThisWorkbook.Path & "\DB-Data.xls")

It worked great!

-=Alejandro

"Jim Thomlinson" wrote in message
...
Thisworkbook.path

will give you the path to the workbook running the code...
--
HTH...

Jim Thomlinson


"Alejandro" wrote:

Hello all,

I am trying to get a macro to open a file in the same directory as the xl
file being launched. The code I am using is:
Workbooks.Open Filename:="DB-Data.xls"

For some reason it doesn't want to find it [although the help file says
that
it should]. If I give it a full path, it has no problem. Is it possible
to
do this? My goal is to get these workbooks available on CD for people to
work at home.

Thanks,
-=Alejandro







All times are GMT +1. The time now is 04:19 PM.

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