Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 45
Default Saving a file automatically everytime it is closed

I'd like to be able to save a copy of a document onto my local drive
everytime I change the original on our server. Is there a macro I can use to
save it automatically everytime the document on the server is closed?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Saving a file automatically everytime it is closed

Set the security level to low/medium in (Tools|Macro|Security). From workbook
press Alt+F11 to launch VBE (Visual Basic Editor). From the left treeview
search for the workbook name and click on + to expand it. Within that you
should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code
pane. The workbook will be saved to c:\ with file name containing date and
time.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Me.Saved = False Then
Me.SaveCopyAs "c:\Backup" & Format(Now(), "YYMMDDhhmmss") & ".xls"
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Wombat" wrote:

I'd like to be able to save a copy of a document onto my local drive
everytime I change the original on our server. Is there a macro I can use to
save it automatically everytime the document on the server is closed?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 45
Default Saving a file automatically everytime it is closed

Doesnt seem to work... I'm using a German version of Excel. Is the
programming language different?

"Jacob Skaria" wrote:

Set the security level to low/medium in (Tools|Macro|Security). From workbook
press Alt+F11 to launch VBE (Visual Basic Editor). From the left treeview
search for the workbook name and click on + to expand it. Within that you
should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code
pane. The workbook will be saved to c:\ with file name containing date and
time.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Me.Saved = False Then
Me.SaveCopyAs "c:\Backup" & Format(Now(), "YYMMDDhhmmss") & ".xls"
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Wombat" wrote:

I'd like to be able to save a copy of a document onto my local drive
everytime I change the original on our server. Is there a macro I can use to
save it automatically everytime the document on the server is closed?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 45
Default Saving a file automatically everytime it is closed

Scrap the last post... I've played around with it and it works! Thanks for
your help

"Jacob Skaria" wrote:

Set the security level to low/medium in (Tools|Macro|Security). From workbook
press Alt+F11 to launch VBE (Visual Basic Editor). From the left treeview
search for the workbook name and click on + to expand it. Within that you
should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code
pane. The workbook will be saved to c:\ with file name containing date and
time.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Me.Saved = False Then
Me.SaveCopyAs "c:\Backup" & Format(Now(), "YYMMDDhhmmss") & ".xls"
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Wombat" wrote:

I'd like to be able to save a copy of a document onto my local drive
everytime I change the original on our server. Is there a macro I can use to
save it automatically everytime the document on the server is closed?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Saving a file automatically everytime it is closed

What if someone screws up and does not want to save the screwed-up changes
to the local drive?

You might want a "Do you want to save changes" option before closing.


Gord Dibben MS Excel MVP


On Wed, 28 Oct 2009 05:33:01 -0700, Wombat
wrote:

I'd like to be able to save a copy of a document onto my local drive
everytime I change the original on our server. Is there a macro I can use to
save it automatically everytime the document on the server is closed?


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
Accidentally closed file without saving Bronwyn Excel Discussion (Misc queries) 6 December 24th 08 03:09 PM
I closed an excel file without saving, is there a way to recover? Nick C Excel Discussion (Misc queries) 1 October 11th 06 06:41 PM
I closed a file without saving it, can i recover the information? karen Excel Discussion (Misc queries) 1 May 17th 06 01:19 AM
How to recover excel file that was closed without saving? JKhatavkar Excel Discussion (Misc queries) 2 October 4th 05 10:42 PM
How can I retrieve a file that was closed without saving? Digvid99 Excel Discussion (Misc queries) 1 February 24th 05 08:59 PM


All times are GMT +1. The time now is 07:29 PM.

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"