View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
DS DS is offline
external usenet poster
 
Posts: 117
Default How to backup excel files?

OK, that gives us a better idea!


If you use:

**************
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim Confirm

Confirm = MsgBox("Do you wish to save and create a backup?", vbYesNo,
"Confirm Backup?")
If Confirm = vbNo Then
Exit Sub
End If

ThisWorkbook.Save

ThisWorkbook.SaveAs "H:\crawsm\MyDocuments\NewName" & Format(Date,
"yyyymmdd") & ".xls"

End Sub
**************

This will save the current copy in its location, and save a backup to the
fodler / file specified with the current date in format yyyymmdd added to the
file name.

It also adds a confirmation request as I mentioned earlier to make sure that
you actually want to save and backup before it does! Just take that out if
it's not suitable for your needs.

HTH
DS


"romelsb" wrote:

tHANKS FOR THE QUICKEST REPLY....your good...let me give specifics...I NEED A
BACKUP UP OF AT LEAST 2 file of the latest update......If i use today the
orig. file, save/close then i will have a backup file on a specified
folder....After one month, if i openmake changessaveclose the same orig.
file then i will have another backup auto filename(lets say with text date)
on the same specified folder...In this stage I have a history
back-ups....Will you help me with this because I need the orig file be used
like a template and at the same time with updated development (i.e. formula,
data, new sheets)....again thanks...more power...pls reply....
--
"Bright minds are blessed to those who share them.."-rsb.


"DS" wrote:

Hi romelsb,

I take it setting the "backup" option in the SaveAs dialog box to
automatically back up your workbook isn't sufficient?

If you use the following, it'll automatically save your workbook in the
current location, and back up your workbook to the specified location on
close. This needs placing in the ThisWorkbook section, rather than in a
module or sheet.

****************
Private Sub Workbook_BeforeClose(Cancel As Boolean)

ThisWorkbook.Save
ThisWorkbook.SaveAs "C:\BackUps\NameIt.xls", Password:="yahoo"

End Sub
****************
You'll obviously need to direct the path above to a valid folder, file name
etc!

WARNING: this will save the workbook on close. If you may want to close
WITHOUT saving, add a yes/no message box to the beginning of the code to
allow the user to exit without saving / backing up. Very useful when you're
doing some development and you make a complete hash of things and just want
to start again from your last save point... as I found out the hard way!!!

HTH
DS





"romelsb" wrote:

Can anybody of good intention, program an excel workbook to provide another
back up file...I had many experience since 1992 wherein after saving and
closing my files and re-open again,,,error will appear and then it is unable
to read....I loss bunch of time using the good functions of excel yet the
program cannot fully protect the users work...I am still hoping that good
VBE tricks may do this ...proofchecksavebackupclose....
--
"Bright minds are blessed to those who share them.."-rsb.