ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Path problem (https://www.excelbanter.com/excel-programming/333626-path-problem.html)

Jay Northrop

Path problem
 
Hello all,

I'm writing an Excel program for a company in an adjacent city. In my
program, I have a macro which opens another workbook in the same directory.
The macro looks like:

Sub OpenInvoicing()
ChDir _
"C:Documents and Settings\JayN\My Documents\Excel Files\SWB"
Workbooks.Open FileName:= _
"C:Documents and Settings\JayN\My Documents\Excel
Files\SWB\Invoicing.xls"
End Sub

The problem is that this will only work on my system because of the path
references. Is there a way to amend this macro so that it will open the
"other" workbook on any system, assuming that it's in the same directory as
the main program?

Thanks for your help!

Jay



Michel Pierron

Path problem
 
Hi Jay, try:
Sub OpenInvoicing()
Workbooks.Open ThisWorkbook.Path & "\Invoicing.xls"
End Sub

MP

"Jay Northrop" a écrit dans le message de news:
50wye.12960$4o.7666@fed1read06...
Hello all,

I'm writing an Excel program for a company in an adjacent city. In my
program, I have a macro which opens another workbook in the same

directory.
The macro looks like:

Sub OpenInvoicing()
ChDir _
"C:Documents and Settings\JayN\My Documents\Excel Files\SWB"
Workbooks.Open FileName:= _
"C:Documents and Settings\JayN\My Documents\Excel
Files\SWB\Invoicing.xls"
End Sub

The problem is that this will only work on my system because of the path
references. Is there a way to amend this macro so that it will open the
"other" workbook on any system, assuming that it's in the same directory

as
the main program?

Thanks for your help!

Jay





Jay Northrop

Path problem
 
Thanks, Michel! This did the trick. I truly appreciate your help on this.

Jeff

"Michel Pierron" wrote in message
...
Hi Jay, try:
Sub OpenInvoicing()
Workbooks.Open ThisWorkbook.Path & "\Invoicing.xls"
End Sub

MP

"Jay Northrop" a écrit dans le message de news:
50wye.12960$4o.7666@fed1read06...
Hello all,

I'm writing an Excel program for a company in an adjacent city. In my
program, I have a macro which opens another workbook in the same

directory.
The macro looks like:

Sub OpenInvoicing()
ChDir _
"C:Documents and Settings\JayN\My Documents\Excel Files\SWB"
Workbooks.Open FileName:= _
"C:Documents and Settings\JayN\My Documents\Excel
Files\SWB\Invoicing.xls"
End Sub

The problem is that this will only work on my system because of the path
references. Is there a way to amend this macro so that it will open the
"other" workbook on any system, assuming that it's in the same directory

as
the main program?

Thanks for your help!

Jay








All times are GMT +1. The time now is 11:59 PM.

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