Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Close a the current workbook and load another specified workbook

Hi,

How do we code in VBA to close the current workbook and load another
specifed one?

For example, I am currently in ABC.xls and I wish to close this workbook and
load DEF.xls....


--
Regards,
Adrian


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Close a the current workbook and load another specified workbook


Activeworkbook.Close
Workbooks.Open filename:="C:\myDir\DEF.xls"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Adrian" wrote in message
...
Hi,

How do we code in VBA to close the current workbook and load another
specifed one?

For example, I am currently in ABC.xls and I wish to close this workbook

and
load DEF.xls....


--
Regards,
Adrian




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default Close a the current workbook and load another specified workbook

Bob Phillips wrote

Activeworkbook.Close
Workbooks.Open filename:="C:\myDir\DEF.xls"


Will the second line really execute if the calling file is closed?

--
David
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Close a the current workbook and load another specified workbook

If the code isn't in the activeworkbook, it'll work ok.

(I'm guessing that there's a 3rd workbook controlling the action.)

David wrote:

Bob Phillips wrote

Activeworkbook.Close
Workbooks.Open filename:="C:\myDir\DEF.xls"


Will the second line really execute if the calling file is closed?

--
David


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Close a the current workbook and load another specified workbook

Adrian,

Try something like

Sub AAA()
Workbooks.Open "DEF.xls"
Workbooks("ABC.xls").Close savechanges:=True
End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Adrian" wrote in message
...
Hi,

How do we code in VBA to close the current workbook and

load another
specifed one?

For example, I am currently in ABC.xls and I wish to close this

workbook and
load DEF.xls....


--
Regards,
Adrian






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
Workbook wont load from shortcut Carol Excel Discussion (Misc queries) 5 September 14th 07 04:04 PM
Load form when workbook opens [email protected] Excel Discussion (Misc queries) 2 July 19th 06 03:32 AM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM
Transparently updating another workbook from the current workbook lothario[_40_] Excel Programming 3 November 2nd 03 01:58 AM
Close current Workbook after calling macro in other Des Janke Excel Programming 4 August 7th 03 07:33 AM


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