Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to check & force open Parent.xls

I have 3 files in the same folder (for simplicity):
Parent.xls, Child1.xls, Child2.xls

Is there a sub I could place in Child1/2.xls which will automatically check
& if necessary "force" open Parent.xls first before Child1/2.xls itself
proceeds to open. I always want Parent.xls to be open before either
Child1.xls or Child2.xls is open. Thanks.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Sub to check & force open Parent.xls

Create a fourth workbook that you ALWAYS open before openning any of the
other three. This workbook's sole function is to open the others in the
correct order.
--
Gary''s Student - gsnu200731


"Max" wrote:

I have 3 files in the same folder (for simplicity):
Parent.xls, Child1.xls, Child2.xls

Is there a sub I could place in Child1/2.xls which will automatically check
& if necessary "force" open Parent.xls first before Child1/2.xls itself
proceeds to open. I always want Parent.xls to be open before either
Child1.xls or Child2.xls is open. Thanks.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---



  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to check & force open Parent.xls

Thanks, GS. It's a discipline to "enforce" onto users who forget to always
open Parent.xls ahead of opening Child1/2.xls, despite reminders. I'm not
sure that asking them to open yet another workbook? would help here. Anyway,
could you share some sample code for try-out?
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Gary''s Student" wrote in message
...
Create a fourth workbook that you ALWAYS open before openning any of the
other three. This workbook's sole function is to open the others in the
correct order.
--
Gary''s Student - gsnu200731



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Sub to check & force open Parent.xls

Here is an example. We have a folder with four sheets:

master.xls
parent.xls
child1.xls
child2.xls

The user is told to ONLY open the master.

The master has the following in workbook code:

Private Sub Workbook_Open()
ChDir "C:\temp"
Workbooks.Open Filename:="C:\temp\parent.xls"
Workbooks.Open Filename:="C:\temp\child1.xls"
Workbooks.Open Filename:="C:\temp\child2.xls"
Windows("master.xls").Activate
ActiveWorkbook.Close
End Sub

So the master opens the working sheets in the proper order and then excuses
itself.

--
Gary''s Student - gsnu200731


"Max" wrote:

Thanks, GS. It's a discipline to "enforce" onto users who forget to always
open Parent.xls ahead of opening Child1/2.xls, despite reminders. I'm not
sure that asking them to open yet another workbook? would help here. Anyway,
could you share some sample code for try-out?
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Gary''s Student" wrote in message
...
Create a fourth workbook that you ALWAYS open before openning any of the
other three. This workbook's sole function is to open the others in the
correct order.
--
Gary''s Student - gsnu200731




  #5   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to check & force open Parent.xls

GS, many thanks. Tried it and it works.

But I'm still hoping that there's a way to effect the force open Parent.xls
directly should the user "inadvertently" proceed to open Child1.xls,
notwithstanding the instructions given.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Gary''s Student" wrote in message
...
Here is an example. We have a folder with four sheets:

master.xls
parent.xls
child1.xls
child2.xls

The user is told to ONLY open the master.

The master has the following in workbook code:

Private Sub Workbook_Open()
ChDir "C:\temp"
Workbooks.Open Filename:="C:\temp\parent.xls"
Workbooks.Open Filename:="C:\temp\child1.xls"
Workbooks.Open Filename:="C:\temp\child2.xls"
Windows("master.xls").Activate
ActiveWorkbook.Close
End Sub

So the master opens the working sheets in the proper order and then
excuses
itself.

--
Gary''s Student - gsnu200731





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Sub to check & force open Parent.xls

Max,

Try something like the following. If Parent.xls is already open, it does
nothing. If Parent.xls is not open, it opens Parent.xls, schedules an
OnTime to cause Excel to re-open the Child.xls workbook, then closes itself.

Sub Auto_Open()
Dim WB As Workbook
On Error Resume Next
Set WB = Workbooks("Parent.xls")
Select Case Err.Number
Case 0
' Parent.xls already open
Case 9
' Parent.xls is not open
Workbooks.Open Filename:="C:\Parent.xls"
Application.OnTime Now, Chr(39) & ThisWorkbook.Name & Chr(39) &
"!DoNothing"
ThisWorkbook.Close savechanges:=True

Case Else
MsgBox "Error: " & CStr(Err.Number) & vbCrLf & _
Err.Description
End Select
End Sub


Sub DoNothing()
' no code required.
End Sub


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



"Max" wrote in message
...
I have 3 files in the same folder (for simplicity):
Parent.xls, Child1.xls, Child2.xls

Is there a sub I could place in Child1/2.xls which will automatically
check & if necessary "force" open Parent.xls first before Child1/2.xls
itself proceeds to open. I always want Parent.xls to be open before either
Child1.xls or Child2.xls is open. Thanks.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---


  #7   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to check & force open Parent.xls

Thanks, Chip. Where should I place the subs, within either Child1.xls &
Child2.xls? Is it within ThisWorkbook? Pl advise.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Chip Pearson" wrote in message
...
Max,

Try something like the following. If Parent.xls is already open, it does
nothing. If Parent.xls is not open, it opens Parent.xls, schedules an
OnTime to cause Excel to re-open the Child.xls workbook, then closes
itself.

Sub Auto_Open()
Dim WB As Workbook
On Error Resume Next
Set WB = Workbooks("Parent.xls")
Select Case Err.Number
Case 0
' Parent.xls already open
Case 9
' Parent.xls is not open
Workbooks.Open Filename:="C:\Parent.xls"
Application.OnTime Now, Chr(39) & ThisWorkbook.Name & Chr(39) &
"!DoNothing"
ThisWorkbook.Close savechanges:=True

Case Else
MsgBox "Error: " & CStr(Err.Number) & vbCrLf & _
Err.Description
End Select
End Sub


Sub DoNothing()
' no code required.
End Sub


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



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
force Excel to open in Internet Explorer bgochal Excel Programming 0 October 19th 06 04:51 PM
Is there a way to force a pop up when spreadsheet is open? mjm Excel Discussion (Misc queries) 4 April 18th 06 08:46 PM
How can force enable macros to be able to open my workbook? kcdonaldson Excel Discussion (Misc queries) 3 December 5th 05 06:16 PM
Force re-open file Jamie[_9_] Excel Programming 1 June 10th 04 12:35 PM


All times are GMT +1. The time now is 11:47 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"