LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Workbooks.Open doesn't open file in ThisWorkbook

I'm attempting to open a 2nd workbook from a command button on the
1st. The 2nd file, in turn, is to open a companion file (File3.xls).
Problem is that "File2" won't open "File3". To test to see if this
code segment was even being executed on startup I placed a MsgBox in
it. The MsgBox always comes up.
However, if I open "File2" directly from Excel everything works OK.

To summarize the results in each case, the sequence is:
Case A: 1) From with Excel, Open File1; 2) Click CommandButton1,
which opens "File2"; 3) MsgBox comes up, but File3 never opens.
Case B: 1) From within Excel, Open File2; 2) MsgBox comes up AND
File3 opens.
What gives?

CODE IN FIRST FILE:
Private Sub CommandButton1_Click()
Workbooks.Open FileName:="C:File2.xls", updatelinks:=True
End Sub

CODE IN 2ND FILE (ThisWorkbook):
Private Sub Workbook_Open()
Workbooks.Open FileName:="C:File3.xls"
' I also tried the following command:
' Application.Workbooks.Open "C:\File3.xls"
prompt = "This works"
dummy = MsgBox(prompt, vbOKOnly, "Test")
End Sub
 
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
2 excel workbooks open up from 1 file; named :1 and :2 - why? pkn Excel Discussion (Misc queries) 1 March 12th 10 03:55 PM
when i open an Excell file 3 workbooks open.Why? Iain40 Excel Discussion (Misc queries) 2 February 3rd 09 05:04 PM
duplicate workbooks open while working in that file rob86021 Excel Discussion (Misc queries) 2 October 16th 07 09:24 PM
When I open Excel, workbooks open automatically. How can I stop t Rhealbird Excel Discussion (Misc queries) 2 February 23rd 06 10:08 AM
Workbooks.Open / .Open Text - How do you stop the .xls addition? Dave[_20_] Excel Programming 2 July 31st 03 04:03 AM


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