Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 709
Default Macro to open Workbook in default path.

OS: MS XP
Excel: 2002

I have (2) two workbooks in the same directory. One workbook opens the other.
The (2) two workbooks will always be together in the same directory but on
occasions the directory will change.

Is there a way in a macro to always use the path of workbook A to open
workbook B?

Thanks in advance.


--
Richard
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Macro to open Workbook in default path.

Maybe this will help
Sub test()
MsgBox ThisWorkbook.Path & "\" & "workbook2name" & ".xls"
End Sub

"Richard" wrote:

OS: MS XP
Excel: 2002

I have (2) two workbooks in the same directory. One workbook opens the other.
The (2) two workbooks will always be together in the same directory but on
occasions the directory will change.

Is there a way in a macro to always use the path of workbook A to open
workbook B?

Thanks in advance.


--
Richard

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Macro to open Workbook in default path.

Richard,

Try something like

Dim PathA As String
PathA = Workbooks("BookA.xls").Path
Workbooks.Open Filename:=PathA & "\" & "BookB.xls"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Richard" wrote in message
...
OS: MS XP
Excel: 2002

I have (2) two workbooks in the same directory. One workbook opens the
other.
The (2) two workbooks will always be together in the same directory but on
occasions the directory will change.

Is there a way in a macro to always use the path of workbook A to open
workbook B?

Thanks in advance.


--
Richard


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
Run a macro when I open a workbook CraigJ Excel Discussion (Misc queries) 1 June 13th 07 04:04 PM
Default a workbook to save as a xlsm (macro-enabled) in 2007 Razzer204 Excel Discussion (Misc queries) 3 March 21st 07 06:10 PM
How to Run Macro in open workbook/s hni Excel Discussion (Misc queries) 1 October 31st 05 10:14 AM
run macro on workbook open kevin Excel Discussion (Misc queries) 3 March 4th 05 10:12 AM
how can I run a macro when I open a workbook? filo666 Excel Discussion (Misc queries) 2 March 2nd 05 07:56 PM


All times are GMT +1. The time now is 11:09 AM.

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

About Us

"It's about Microsoft Excel"