View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
toothfish__[_2_] toothfish__[_2_] is offline
external usenet poster
 
Posts: 4
Default Workbook backup before opening?

Dave Peterson wrote in message ...
Is this code in your c:\current.xls workbook?

If yes, then I don't think filecopy will work with an open file.

You may want to look at savecopyas in vba's help:

Option Explicit
Private Sub Workbook_Open()
ThisWorkbook.SaveCopyAs "C:\backup\Current_" _
& Format(Date, "YYMMDD") & ".xls"
End Sub

If you're using the code in a different workbook, then never mind.


thanks Dave,

yes the code was in the c:\current.xls workbook and FileCopy then
prompted a "permission denied" error. So have adapted the SaveCopyAs
and works perfectly now.

appreciate your help.