ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close a the current workbook and load another specified workbook (https://www.excelbanter.com/excel-programming/306301-close-current-workbook-load-another-specified-workbook.html)

Adrian[_7_]

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



Bob Phillips[_6_]

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





David

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

Dave Peterson[_3_]

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


Chip Pearson

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






All times are GMT +1. The time now is 08:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com