Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Add-in problem; button changes add-in path | Excel Programming | |||
Dir Path Code Problem | Excel Programming | |||
Personal.XLS path problem | Excel Programming | |||
File Path Problem | Excel Programming | |||
SendKeys and Path Problem | Excel Programming |