Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default 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


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to close a excel file using Macro coding? Eric Excel Discussion (Misc queries) 1 June 11th 07 08:49 AM
How to code the Macro to save and close a file? Eric Excel Discussion (Misc queries) 7 June 10th 07 03:28 PM
Macro to Open, then Close another File HROBERTSON Excel Discussion (Misc queries) 1 January 8th 07 06:41 PM
recrding macro,copy data thn close file, get messge abut clpbord PaddyBoy Excel Discussion (Misc queries) 2 October 25th 06 04:38 AM
macro to close excel Pam C Excel Discussion (Misc queries) 1 May 5th 05 04:43 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"