file save

ashtod1

Board Regular
Joined
Sep 5, 2005
Messages
93
Hi is there a way of using a macro to automatically save a file at certain times
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hello, ashtod1,

so you want more then the autosave for recovery in case of problems ?

would this do ?
in the workbookmodule
Code:
Option Explicit

Private Sub Workbook_Open()
sec = 300
Run "do_something"
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Run "stop_it"
End Sub
"normal module"
Code:
Option Explicit

Public sec As Integer
Public when As Variant

Sub do_something()
when = Now + sec / 60 / 60 / 24
Application.OnTime when, "do_something"
ThisWorkbook.Save
End Sub

Private Sub stop_it()
Application.OnTime EarliestTime:=when, Procedure:="do_something", schedule:=False
End Sub
this will save the workbook each 300 seconds

kind regards,
Erik
 
Upvote 0
thanks for that it works really well but can i get it to save to a different directory than the original e.g back-up folder
 
Upvote 0
thanks for that it works really well but can i get it to save to a different directory than the original e.g back-up folder
of course
did you look for SaveAs somewhere ?
shouldn't be to difficult to find it in the helpfiles or here on the board
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,864
Members
449,052
Latest member
Fuddy_Duddy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top