Solved

auto open excel workbook

Posted on 2013-01-29
8
285 Views
Last Modified: 2013-01-29
Hi
I have muliple workbooks in the same folder.
One master workbook is referenced by several of the other workbooks with data flowing both ways between the master and the dependents.
I would like the master workbook to be opened automatically whenever any of the dependent workbooks are opened.
The master workbook and the dependent/s to remain open until the operator manually closes/saves them.
Thanks
David
0
Comment
Question by:DAVID131
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 26

Expert Comment

by:redmondb
ID: 38830791
David,

You'd need an Auto_Open (or Workbook_Open) macro in each of the dependent workbooks. Is that acceptable? Code would be as simple as the following...
Sub Auto_Open()

Workbooks.Open ("D:\Master.xlsx")

End Sub

Open in new window

Regards,
Brian.
0
 

Author Comment

by:DAVID131
ID: 38830872
Thanks Brian

Very simple answer but the folder is portable and could be sitting in any one of a number of drives so I could not hard code in "D:
Can I get around this by somehow coding in that the filepath is the same as the open workbook?

David
0
 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
ID: 38830923
David,

Sure...
Sub Auto_Open()

Workbooks.Open (thisworkbook.Path & "\" & "Master.xlsx")

End Sub

Open in new window

Regards,
Brian.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:DAVID131
ID: 38831004
Thanks Brian
Works a treat
David
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38831119
Thanks, David.
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38831133
David,

Oops, if the master is already open, you don't want an attempt to re-open it, so...
Option Explicit

Sub Auto_Open()

If Book_Exists("Master.xlsx") Then Exit Sub

Workbooks.Open (ThisWorkbook.Path & "\" & "Master.xlsx")

End Sub

Function Book_Exists(xBook_Name As String) As Boolean

Book_Exists = False

On Error Resume Next
    Book_Exists = (Workbooks(xBook_Name).Name = xBook_Name)
On Error GoTo 0

End Function

Open in new window

Regards,
Brian.
0
 

Author Comment

by:DAVID131
ID: 38831159
Thanks Brian
Had not thought about that!
David
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38831454
All part of the (belated!) service, David.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Pivot tables that only has data for one section - how to do it.. 4 45
Increment default InPutBox value 14 26
Converting time 4 44
VB.Net  Exporting Excel Woorkbook to PDF 7 60
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question