View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
SeanC UK[_2_] SeanC UK[_2_] is offline
external usenet poster
 
Posts: 63
Default workbook saved in different position

Hi Li,

I think there is a problem with your SaveAs line. Try:

bk.SaveAs Filename:= fname

with the colon after Filename.

Sean.

--
(please remember to click yes if replies you receive are helpful to you)


"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