LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default workbook saved in different position

First, I would use a dedicated macro that I ran when I wanted to do this. I
wouldn't want to use the _Beforeclose event--just in case I screwed up the
workbook and didn't want to save it!

But you could try this untested, uncompiled code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim fname As String
fname = "H:\2009\payment\payment.xls"
me.Save
me.SavecopyAs Filename:=fname
End Sub

Li Jianyong wrote:

I am working on a workbook, when I close the book, I want to save it into
two path. I have programmed following macro,but when I close the workbook, it
doesn't save a copy as I suppose.

my workbook is named "payment.xls"

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim bk As Workbook

Dim fname As String

fname = "H:\2009\payment\payment.xls"

Set bk = Workbooks("payment.xls")


bk.Save


bk.SaveAs Filename = fname


End Sub


--

Dave Peterson


 
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
Why is Referenced Workbook Saved When ActiveWorkbook is Saved? RyanH Excel Programming 1 October 29th 08 08:20 PM
Remembering position in shared workbook David Trimboli Excel Discussion (Misc queries) 0 June 14th 07 02:21 PM
Save column J of WorkBook when WorkBook is not saved. mikeburg[_84_] Excel Programming 2 June 14th 06 09:57 PM
Return position of a sheet in a workbook XP Excel Programming 4 February 6th 06 09:30 PM
How can I see a copy of a saved workbook before I saved it again? Norma Excel Worksheet Functions 2 May 11th 05 10:31 AM


All times are GMT +1. The time now is 07:57 AM.

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"