Solved

auto open excel workbook

Posted on 2013-01-29
8
271 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
  • 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.Range Set 25 78
Find and Replace Function not working in Excel 13 50
Excel Need to return the text of a filter column 11 22
formula how to get the number incrementor? 3 23
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

832 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