Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Setup / January 2008

Tip: Looking for answers? Try searching our database.

can I create backup file in separate folder from the original?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MCC Wong - 15 Jan 2008 11:59 GMT
Is is possible to automatically create a backup file once we update an excel
file in a separate folder from the folder with the original excel file.  The
reason is that we are afraid that someone might delete the folder
accidentally and lost all the both the original file and the backup file.

We are using Microsoft Excel 2003
Gord Dibben - 15 Jan 2008 19:57 GMT
Only through VBA code which makes a backup copy of the file in another folder of
your choice when saved.

Private Sub Workbook_BeforeSave(ByVal _
SaveAsUI As Boolean, Cancel As Boolean)
Application.DisplayAlerts = False
   ActiveWorkbook.SaveCopyAs Filename:="C:\Gordstuff\" & _
           ActiveWorkbook.Name
   ActiveWorkbook.Save
   Application.DisplayAlerts = True
End Sub

On the other hand, why don't you just regularly make a backup of the folder?

You should be doing that with all your data files and folders as a routine.

Gord Dibben  MS Excel MVP

>Is is possible to automatically create a backup file once we update an excel
>file in a separate folder from the folder with the original excel file.  The
>reason is that we are afraid that someone might delete the folder
>accidentally and lost all the both the original file and the backup file.
>
>We are using Microsoft Excel 2003
MCC Wong - 16 Jan 2008 12:16 GMT
Thanks Dibben,

I've tried the VBA code, but not successful.  Since I'm not familiar with
using VBA code or writing macro, can you teach me how to do it??

I have created a shared electronic bank book namely 'HSBC.xls' in J drive
and when I save this file, I would like to make a backup copy in C drive
namely 'Backup HSBC', but I don't know exactly how to write VBA code.

Should I use the macro function or the Visual Basic Editor under Tools??
Please teach me how to write the macro or VBA code!!

I've tried the following as suggested but won't work:

Sub HSBC (ByValSaveASUI As Boolean, Cancel As Boolean)
Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAs "C:\Backup HSBC.xls" & ActiveWorkbook.Name
ActiveWorkbook.Save
Application.DisplayAlerts = True
End Sub

What have I done wrong?? please advice!!

MCC

> Only through VBA code which makes a backup copy of the file in another folder of
> your choice when saved.
[quoted text clipped - 20 lines]
> >
> >We are using Microsoft Excel 2003
Gord Dibben - 17 Jan 2008 00:11 GMT
You have made too many changes to the code I posted.

Try this one and do not make any more changes.

Private Sub Workbook_BeforeSave (ByValSaveASUI As Boolean, Cancel As Boolean)
Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAs "C:\Backup HSBC\" & ActiveWorkbook.Name
ActiveWorkbook.Save
Application.DisplayAlerts = True
End Sub

Copy this code as is then in top left corner of Excel Menu bar left of "File"
right-click on the Excel Icon and "View Code"

Paste the code into that module.

Alt + q to return to Excel window.  Save your workbook.

Go look in BackupHSBC folder.

Gord

>Thanks Dibben,
>
[quoted text clipped - 45 lines]
>> >
>> >We are using Microsoft Excel 2003
MCC Wong - 18 Jan 2008 06:11 GMT
Dear Dibben,

I've just copied your code but the feedback shows the following message:
"Complie error:
Procedure declaration does not match description of event or procedure
having the same name."
and the first code "Private Sub Workbook_BeforeSave (ByValSaveASUI As
Boolean, Cancel As Boolean)" is being highlighted.

Please advice.

MCC

> You have made too many changes to the code I posted.
>
[quoted text clipped - 67 lines]
> >> >
> >> >We are using Microsoft Excel 2003
Dave Peterson - 18 Jan 2008 15:18 GMT
You changed Gord's original code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

ByVal SaveAsUi are two separate words.

> Dear Dibben,
>
[quoted text clipped - 80 lines]
> > >> >
> > >> >We are using Microsoft Excel 2003

Signature

Dave Peterson

Gord Dibben - 19 Jan 2008 01:03 GMT
I think OP is typing, rather than just copy/pasting.

>You changed Gord's original code:
>
[quoted text clipped - 86 lines]
>> > >> >
>> > >> >We are using Microsoft Excel 2003
Dave Peterson - 19 Jan 2008 01:05 GMT
If it's more than 3 characters, that's usually a mistake! <vbg>

> I think OP is typing, rather than just copy/pasting.
>
[quoted text clipped - 88 lines]
> >> > >> >
> >> > >> >We are using Microsoft Excel 2003

Signature

Dave Peterson

Gord Dibben - 19 Jan 2008 01:06 GMT
Although I must admit, I compounded the error by copying some of his first
incorrect attempt at making changes by leaving the "ByValSaveASUI" in my second
posting.

Gord

>I think OP is typing, rather than just copy/pasting.
>
[quoted text clipped - 88 lines]
>>> > >> >
>>> > >> >We are using Microsoft Excel 2003
CLR - 16 Jan 2008 13:46 GMT
If you are working for a Company, with a MIS department, they usually have a
regular schedule of making backups of all files.  Check with them, and
negotiate your needs.

Vaya con Dios,
Chuck, CABGx3

> Is is possible to automatically create a backup file once we update an excel
> file in a separate folder from the folder with the original excel file.  The
> reason is that we are afraid that someone might delete the folder
> accidentally and lost all the both the original file and the backup file.
>
> We are using Microsoft Excel 2003

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.