Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,670
Default How to code the Macro to save and close a file?

Workbooks.Open Filename:="C:\Files\1.xls", _
UpdateLinks:=3
ActiveWorkbook.Save
ActiveWindow.Close
The command "ActiveWindow" cannot be performed, does anyone have any
suggestions on how change the code for specific file under specific
directory, such as
Save "C:\Files\1.xls" to replace the code ActiveWorkbook.Save
Close "C:\Files\1.xls" to replace the code ActiveWorkbook.Close

Thank for any suggestions
Eric

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default How to code the Macro to save and close a file?

Set oWB = Workbooks.Open (Filename:="C:\Files\1.xls", _
UpdateLinks:=3)
oWb.Save
oWb.Close

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Eric" wrote in message
...
Workbooks.Open Filename:="C:\Files\1.xls", _
UpdateLinks:=3
ActiveWorkbook.Save
ActiveWindow.Close
The command "ActiveWindow" cannot be performed, does anyone have any
suggestions on how change the code for specific file under specific
directory, such as
Save "C:\Files\1.xls" to replace the code ActiveWorkbook.Save
Close "C:\Files\1.xls" to replace the code ActiveWorkbook.Close

Thank for any suggestions
Eric



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,670
Default How to code the Macro to save and close a file?

Thank everyone for suggestions

I try this by typing following codes into Macro,
but the command Save and Close cannot be performed.
Do you have any suggestions on how to fix this?
Thank everyone very much for any suggestions
Eric

"Bob Phillips" wrote:

Set oWB = Workbooks.Open (Filename:="C:\Files\1.xls", _
UpdateLinks:=3)
oWb.Save
oWb.Close

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Eric" wrote in message
...
Workbooks.Open Filename:="C:\Files\1.xls", _
UpdateLinks:=3
ActiveWorkbook.Save
ActiveWindow.Close
The command "ActiveWindow" cannot be performed, does anyone have any
suggestions on how change the code for specific file under specific
directory, such as
Save "C:\Files\1.xls" to replace the code ActiveWorkbook.Save
Close "C:\Files\1.xls" to replace the code ActiveWorkbook.Close

Thank for any suggestions
Eric




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default How to code the Macro to save and close a file?

Why? What happens? What messages do you get?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Eric" wrote in message
...
Thank everyone for suggestions

I try this by typing following codes into Macro,
but the command Save and Close cannot be performed.
Do you have any suggestions on how to fix this?
Thank everyone very much for any suggestions
Eric

"Bob Phillips" wrote:

Set oWB = Workbooks.Open (Filename:="C:\Files\1.xls", _
UpdateLinks:=3)
oWb.Save
oWb.Close

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Eric" wrote in message
...
Workbooks.Open Filename:="C:\Files\1.xls", _
UpdateLinks:=3
ActiveWorkbook.Save
ActiveWindow.Close
The command "ActiveWindow" cannot be performed, does anyone have any
suggestions on how change the code for specific file under specific
directory, such as
Save "C:\Files\1.xls" to replace the code ActiveWorkbook.Save
Close "C:\Files\1.xls" to replace the code ActiveWorkbook.Close

Thank for any suggestions
Eric






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,670
Default How to code the Macro to save and close a file?

Set oWB = Workbooks.Open (Filename:="C:\Files\1.xls", _
UpdateLinks:=3)
oWb.Save
oWb.Close

Once the file is opened and get updated. There is no Save and Close actions
at all, and the file keeps open as it is.

Does it have anything wrong with the code?
Thank for any suggestions
Eric

"Bob Phillips" wrote:

Why? What happens? What messages do you get?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Eric" wrote in message
...
Thank everyone for suggestions

I try this by typing following codes into Macro,
but the command Save and Close cannot be performed.
Do you have any suggestions on how to fix this?
Thank everyone very much for any suggestions
Eric

"Bob Phillips" wrote:

Set oWB = Workbooks.Open (Filename:="C:\Files\1.xls", _
UpdateLinks:=3)
oWb.Save
oWb.Close

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Eric" wrote in message
...
Workbooks.Open Filename:="C:\Files\1.xls", _
UpdateLinks:=3
ActiveWorkbook.Save
ActiveWindow.Close
The command "ActiveWindow" cannot be performed, does anyone have any
suggestions on how change the code for specific file under specific
directory, such as
Save "C:\Files\1.xls" to replace the code ActiveWorkbook.Save
Close "C:\Files\1.xls" to replace the code ActiveWorkbook.Close

Thank for any suggestions
Eric









  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default How to code the Macro to save and close a file?

Here is a tiny example. Start in some workbook.

Want to open x.xls.
Want to update it.
Want to save x.xls
Want to close x.xls

Sub eric()
Workbooks.Open Filename:="C:\x.xls", UpdateLinks:=3
Workbooks("x.xls").Activate
Range("A1").Value = 21
Workbooks("x.xls").Save
Workbooks("x.xls").Close
End Sub
--
Gary''s Student - gsnu200728


"Eric" wrote:

Workbooks.Open Filename:="C:\Files\1.xls", _
UpdateLinks:=3
ActiveWorkbook.Save
ActiveWindow.Close
The command "ActiveWindow" cannot be performed, does anyone have any
suggestions on how change the code for specific file under specific
directory, such as
Save "C:\Files\1.xls" to replace the code ActiveWorkbook.Save
Close "C:\Files\1.xls" to replace the code ActiveWorkbook.Close

Thank for any suggestions
Eric

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,670
Default How to code the Macro to save and close a file?

Thank everyone for suggestions

I try following codes too,
Sub eric()
Workbooks.Open Filename:="C:\x.xls", UpdateLinks:=3
Workbooks("x.xls").Activate
Range("A1").Value = 21
Workbooks("x.xls").Save
Workbooks("x.xls").Close
End Sub


The file gets undated, but stop to perform save and close action
Do you have any suggestions?
Thank everyone for suggestions
Eric


"Gary''s Student" wrote:

Here is a tiny example. Start in some workbook.

Want to open x.xls.
Want to update it.
Want to save x.xls
Want to close x.xls

Sub eric()
Workbooks.Open Filename:="C:\x.xls", UpdateLinks:=3
Workbooks("x.xls").Activate
Range("A1").Value = 21
Workbooks("x.xls").Save
Workbooks("x.xls").Close
End Sub
--
Gary''s Student - gsnu200728


"Eric" wrote:

Workbooks.Open Filename:="C:\Files\1.xls", _
UpdateLinks:=3
ActiveWorkbook.Save
ActiveWindow.Close
The command "ActiveWindow" cannot be performed, does anyone have any
suggestions on how change the code for specific file under specific
directory, such as
Save "C:\Files\1.xls" to replace the code ActiveWorkbook.Save
Close "C:\Files\1.xls" to replace the code ActiveWorkbook.Close

Thank for any suggestions
Eric

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 524
Default How to code the Macro to save and close a file?

Sun, 10 Jun 2007 05:00:01 -0700 from Eric
:
Workbooks.Open Filename:="C:\Files\1.xls", _


Please don't post the same query multiple times.

http://oakroadsystems.com/genl/unice.htm#xpost

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
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
Macro to save & close all opened files James A Excel Discussion (Misc queries) 1 December 23rd 06 05:16 AM
VBA Code to kick off macro when workbook command to close is initi zulfer7 Excel Discussion (Misc queries) 2 June 23rd 06 08:04 PM
Macro VBA code to name Save-As file Dolores Excel Worksheet Functions 7 December 28th 05 11:24 PM
File close excel does not ask me to save changes Cathy Humphreys Excel Discussion (Misc queries) 2 June 13th 05 08:48 PM
I can't save a file unless I close all excel instances or it's th. BVBOWES Excel Discussion (Misc queries) 0 April 26th 05 09:20 PM


All times are GMT +1. The time now is 07:29 PM.

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

About Us

"It's about Microsoft Excel"