Archive for May, 2012

Simple Excel Autosave Macro

Wednesday, May 30th, 2012

Add the following code under ThisWorkbook module in your workbook:

Private Seconds As Integer

Private Sub Workbook_Open()
    Seconds = 300 ‘ 5 minutes. Adjust as you wish
    ScheduleSaving
End Sub

Sub ScheduleSaving()
    Application.OnTime Now + Seconds / 24 / 3600, “ThisWorkbook.SaveMyWorkbook”, Now + 1.5 * Seconds / 24 / 3600
End Sub

Sub SaveMyWorkbook()
    Debug.Print “Saving workbook…”
    ThisWorkbook.Save
    Debug.Print “Saved workbook.”
    ScheduleSaving
End Sub