Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Why is Referenced Workbook Saved When ActiveWorkbook is Saved? | Excel Programming | |||
Remembering position in shared workbook | Excel Discussion (Misc queries) | |||
Save column J of WorkBook when WorkBook is not saved. | Excel Programming | |||
Return position of a sheet in a workbook | Excel Programming | |||
How can I see a copy of a saved workbook before I saved it again? | Excel Worksheet Functions |