ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to open workbook without hardcoding path (https://www.excelbanter.com/excel-programming/283067-how-open-workbook-without-hardcoding-path.html)

Michael Turner

how to open workbook without hardcoding path
 
Hi

Could anyone tell me how to open a workbook from another workbook, where
both files are in the same folder, without hardcoding the path. I have tried
code like this without success.
Workbooks.open (path & "\somefile.xls")

Thanks in advance
Mick



Jan Karel Pieterse

how to open workbook without hardcoding path
 
Hi Michael,

Workbooks.open (path & "\somefile.xls")


Workbooks.open thisworkbook.path & "\somefile.xls"

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com


Harald Staff

how to open workbook without hardcoding path
 
Hi Mick

Youre sooo close:
Workbooks.Open ThisWorkbook.Path & "\somefile.xls"

--
HTH. Best wishes Harald
Followup to newsgroup only please

"Michael Turner" skrev i melding
...
Hi

Could anyone tell me how to open a workbook from another workbook, where
both files are in the same folder, without hardcoding the path. I have

tried
code like this without success.
Workbooks.open (path & "\somefile.xls")

Thanks in advance
Mick





Paul Robinson

how to open workbook without hardcoding path
 
Hi,
Try
Workbooks.open (ThisWorkbook.path & "\somefile.xls")

ThisWorkbook in VBA is the one containing the code.

regards
Paul

"Michael Turner" wrote in message ...
Hi

Could anyone tell me how to open a workbook from another workbook, where
both files are in the same folder, without hardcoding the path. I have tried
code like this without success.
Workbooks.open (path & "\somefile.xls")

Thanks in advance
Mick



All times are GMT +1. The time now is 01:37 PM.

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