Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Backup on file open

Hi All. I want to backup a file when it opens. I've seen threads that tell
how to backup on close, but not on open. The problem I'm having is that when
I "FileSaveAs" the SaveAs workbook becomes the active workbook. After I
SaveAs I want to close the SaveAs and re-activate the original. Here is what
I have that doesn't work. I get a "Run-time error '9': Suscript out of range"
error message on the line "Workbooks("GFG16.xls").Activate".

Sub Auto_Open()
Worksheets("Main!A1").Select
If MsgBox("Do you want to backup before beginning?", vbYesNo) = vbNo Then
Exit Sub
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="C:\Program Files\Microsoft
Office\Office\Golf\GFG16Bak.xls"
Workbooks("GFG16.xls").Activate
Workbooks("GFG16Bak.xls").Activate
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub

What is the best way to accomplish my task?
Thanks,
--
Jim T
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Backup on file open

Use SaveCopyAs

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jim Tibbetts" wrote in message
...
Hi All. I want to backup a file when it opens. I've seen threads that tell
how to backup on close, but not on open. The problem I'm having is that

when
I "FileSaveAs" the SaveAs workbook becomes the active workbook. After I
SaveAs I want to close the SaveAs and re-activate the original. Here is

what
I have that doesn't work. I get a "Run-time error '9': Suscript out of

range"
error message on the line "Workbooks("GFG16.xls").Activate".

Sub Auto_Open()
Worksheets("Main!A1").Select
If MsgBox("Do you want to backup before beginning?", vbYesNo) = vbNo

Then
Exit Sub
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="C:\Program Files\Microsoft
Office\Office\Golf\GFG16Bak.xls"
Workbooks("GFG16.xls").Activate
Workbooks("GFG16Bak.xls").Activate
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub

What is the best way to accomplish my task?
Thanks,
--
Jim T



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Backup on file open

Thanks bob. I guess I didn't dig deep enuf in Help. Works perfectly.
--
Jim T


"Bob Phillips" wrote:

Use SaveCopyAs

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jim Tibbetts" wrote in message
...
Hi All. I want to backup a file when it opens. I've seen threads that tell
how to backup on close, but not on open. The problem I'm having is that

when
I "FileSaveAs" the SaveAs workbook becomes the active workbook. After I
SaveAs I want to close the SaveAs and re-activate the original. Here is

what
I have that doesn't work. I get a "Run-time error '9': Suscript out of

range"
error message on the line "Workbooks("GFG16.xls").Activate".

Sub Auto_Open()
Worksheets("Main!A1").Select
If MsgBox("Do you want to backup before beginning?", vbYesNo) = vbNo

Then
Exit Sub
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="C:\Program Files\Microsoft
Office\Office\Golf\GFG16Bak.xls"
Workbooks("GFG16.xls").Activate
Workbooks("GFG16Bak.xls").Activate
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub

What is the best way to accomplish my task?
Thanks,
--
Jim T




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Everytime i close an excel file, it creates a new backup file p Excel Discussion (Misc queries) 3 November 22nd 07 08:13 AM
Create an automatic backup file on open in EXCEL? bjohnsonnc Excel Discussion (Misc queries) 1 September 20th 07 04:45 PM
how can open backup file Tufail Excel Discussion (Misc queries) 4 February 14th 07 09:39 PM
Saving backup file on file open AmyTaylor[_32_] Excel Programming 4 January 10th 06 02:48 PM
Backup Spreadsheet while open Sean Excel Discussion (Misc queries) 2 August 5th 05 06:50 AM


All times are GMT +1. The time now is 05:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"