ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I close a workbook using VBA? (https://www.excelbanter.com/excel-programming/293110-how-can-i-close-workbook-using-vba.html)

Trevor[_4_]

How can I close a workbook using VBA?
 
I have a workbook open that contains a macro which needs
to access another workbook. I have added code to open the
workbook and perform the necessary functions, but how do I
then close that workbook while leaving the active one open
to continue with execution? The file I need to open and
subsequently close is called 'coll codes.xls'.

Any help would be appreciated.

Thanks,

Trevor

Vasant Nanavati

How can I close a workbook using VBA?
 
Workbooks("coll codes.xls").Close True 'False

Use the True parameter if you want changes saved; False otherwise.

--

Vasant


"Trevor" wrote in message
...
I have a workbook open that contains a macro which needs
to access another workbook. I have added code to open the
workbook and perform the necessary functions, but how do I
then close that workbook while leaving the active one open
to continue with execution? The file I need to open and
subsequently close is called 'coll codes.xls'.

Any help would be appreciated.

Thanks,

Trevor




Tom Ogilvy

How can I close a workbook using VBA?
 
ActiveWorkbook.Close SaveChanges:=False

--
Regards,
Tom Ogilvy

"Trevor" wrote in message
...
I have a workbook open that contains a macro which needs
to access another workbook. I have added code to open the
workbook and perform the necessary functions, but how do I
then close that workbook while leaving the active one open
to continue with execution? The file I need to open and
subsequently close is called 'coll codes.xls'.

Any help would be appreciated.

Thanks,

Trevor





All times are GMT +1. The time now is 08:58 AM.

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