?
Solved

auto open excel workbook

Posted on 2013-01-29
8
Medium Priority
?
298 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 2000 total points
ID: 38830923
David,

Sure...
Sub Auto_Open()

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

End Sub

Open in new window

Regards,
Brian.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

765 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