Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Add-in problem; button changes add-in path John Mason Excel Programming 0 May 20th 04 04:22 AM
Dir Path Code Problem Todd Huttenstine Excel Programming 2 April 1st 04 11:27 PM
Personal.XLS path problem Lenonardo Excel Programming 2 January 10th 04 05:39 PM
File Path Problem Todd Huttenstine[_2_] Excel Programming 3 December 22nd 03 08:44 PM
SendKeys and Path Problem rdcord Excel Programming 3 September 11th 03 06:12 PM


All times are GMT +1. The time now is 12:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"