ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to close a excel file using Macro coding? (https://www.excelbanter.com/excel-discussion-misc-queries/145968-how-close-excel-file-using-macro-coding.html)

Eric

How to close a excel file using Macro coding?
 
Referring to the post in Worksheet Function

Once I open the file 1.xls, and try to run following Macro.
There is an error message "Array exceeds the range" [Translation from Chinese]

Sub Eric()
Workbooks("E:\1.xls").Close
End Sub

Does anyone have any suggestions what wrong is the above code? and how to
fix it?
Thanks in advance for any suggestions
Eric


Mike H

How to close a excel file using Macro coding?
 
You might try instead:-

Sub Eric()
ActiveWorkbook.Close savechanges = True 'Or if you want False
End Sub


Mike


"Eric" wrote:

Referring to the post in Worksheet Function

Once I open the file 1.xls, and try to run following Macro.
There is an error message "Array exceeds the range" [Translation from Chinese]

Sub Eric()
Workbooks("E:\1.xls").Close
End Sub

Does anyone have any suggestions what wrong is the above code? and how to
fix it?
Thanks in advance for any suggestions
Eric



All times are GMT +1. The time now is 06:13 AM.

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