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

your correct...line breaks...can u pls gave me this considering that I can
just copy and paste it on another workbooks....can u make it constant on
"orig. filename + textdate line" then I will just type in the back-up
folder....is it possible....I try to type in the real filename then save then
when i try to close the workbook...i cant click the fileclose button....were
almost finish i think...pls reply...
--
"Bright minds are blessed to those who share them.."-rsb.


"DS" wrote:

that's just a copy & paste issue, it's inserted a line break from here where
there shouldn't be one!

If you see in the editor:

***
Confirm = MsgBox("Do you wish to save and create a backup?", vbYesNo,
"Confirm Backup?")
***

then just delete the line break between the two so all that appears as a
single line. That should fix it.

HTH
DS



"romelsb" wrote:

thanks...i had tried...see this line
i do as instructed
upon closing
syntax error pop-up
vbe opened
then the ine below is highlighted

Confirm = MsgBox("Do you wish to save and create a backup?", vbYesNo,

pls...continue to reply
--
"Bright minds are blessed to those who share them.."-rsb.


"DS" wrote:

Hi romelsb,

OK, here we go.

Open your Excel workbook, and along the top, click the following (each will
open after the other):

Tools - Macro - Visual Basic Editor

You should see a number of panes, split across the screen. On your left
should be a pane headed "Project - VBA Project", with a list of items below
it. One of these should be your item, something like "VBA Project
(DEVELOPER.xls)". Click on the plus symbol, and you should see some more
options underneath, including "Microsoft Excel Objects". Click the plus
symbol next to this, and you'll see a long list, of every sheet in the
workbook,as well as, at the bottom "ThisWorkbook".

Double-click "ThisWorkbook" and you'll get an editor pane open up in the
main body. Copy the following and paste it into that pane. Then close the
editor, and save the workbook.

*********************
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 "C:\backups\Developer_" & Format(Date, "yyyymmdd") &
".xls"

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

This will save the current version in place, and a copy to the folder
"C:\Backups" (which you'll need to create before first use), and the backup
copy will be named as "Developer_20061102.xls" (example as one done today, it
will update as per the date actioned).

Done and done.
HTH
DS


"romelsb" wrote:

ooopss...so good....sorry i dont know how to place it in VBE...can u tech me
just for this sake....I need the backup filename just like u
formatted.....will it be like this...
if filename of orig. workbook is "DEVELOPER.xls"
then
does the first backup will be this "DEVELOPER 2006NOV02.xls"
THANKS A LOT....pls reply back...

--
"Bright minds are blessed to those who share them.."-rsb.


"DS" wrote:

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.