ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How to close a excel file using Macro coding? (https://www.excelbanter.com/excel-worksheet-functions/145975-how-close-excel-file-using-macro-coding.html)

Eric

How to close a excel file using Macro coding?
 
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


JMB

How to close a excel file using Macro coding?
 
Try:
Workbooks("1.xls").Close


"Eric" wrote:

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


Dave Peterson

How to close a excel file using Macro coding?
 
Workbooks("1.xls").Close

You don't specify the drive and path when you use that workbooks(...)
collection.

Eric wrote:

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


--

Dave Peterson

Eric

How to close a excel file using Macro coding?
 
I already specify the drive and path, but it still does not work.
Does anyone know how to solve this coding for closing a file?
Thank for any suggestions
Eric

"Dave Peterson" wrote:

Workbooks("1.xls").Close

You don't specify the drive and path when you use that workbooks(...)
collection.

Eric wrote:

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


--

Dave Peterson


Dave Peterson

How to close a excel file using Macro coding?
 
Don't specify the drive and path.

Do NOT specify the drive and path.

Eric wrote:

I already specify the drive and path, but it still does not work.
Does anyone know how to solve this coding for closing a file?
Thank for any suggestions
Eric

"Dave Peterson" wrote:

Workbooks("1.xls").Close

You don't specify the drive and path when you use that workbooks(...)
collection.

Eric wrote:

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


--

Dave Peterson


--

Dave Peterson

Eric

How to close a excel file using Macro coding?
 
Thank everyone for suggestions

The following code is created under Report.xls
When I open Report.xls, then go to toolsMarcro, select Updating and click
RUN button, then it opens 1.xls file, save it and close it.
However, when I open Report.xls, use the hot key Ctrl+Shift+u, it is still
able to open 1.xls file, but it does not able to save it and close it.
Do you have any suggestions what wrong it is when I use the hot key to run
macro?

Sub Updating()
' Ctrl+Shift+u for hot key
Workbooks.Open Filename:="C:\files\1.xls", UpdateLinks:=3
Workbooks("1.xls").Activate
Workbooks("1.xls").Save
Workbooks("1.xls").Close
End Sub

Thank everyone very much for suggestions
Eric

"Dave Peterson" wrote:

Don't specify the drive and path.

Do NOT specify the drive and path.

Eric wrote:

I already specify the drive and path, but it still does not work.
Does anyone know how to solve this coding for closing a file?
Thank for any suggestions
Eric

"Dave Peterson" wrote:

Workbooks("1.xls").Close

You don't specify the drive and path when you use that workbooks(...)
collection.

Eric wrote:

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

--

Dave Peterson


--

Dave Peterson



All times are GMT +1. The time now is 12:19 AM.

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