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
|