Path problem

  • Thread starter Thread starter Jay Northrop
  • Start date Start date
J

Jay Northrop

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
 
Hi Jay, try:
Sub OpenInvoicing()
Workbooks.Open ThisWorkbook.Path & "\Invoicing.xls"
End Sub

MP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top