Word

Autosave document at selected intervals or run other code at intervals

Ease of Use

Easy

Version tested with

2003 

Submitted by:

mdmackillop

Description:

Documents based on this template will prompt for a save location on creation and will save automatically at defined intervals. 

Discussion:

Reduce the risk of closing without saving. The document will save every 15 seconds (as set) If you need to run any code at intervals, the same methodology can be used. 

Code:

instructions for use

			

'In "ThisDocument" module Option Explicit Private Sub Document_New() ActiveDocument.Save SaveTime End Sub 'In a standard module Option Explicit Sub SaveTime() Application.OnTime When:=Now + TimeValue("00:00:15"), _ Name:="DoSave" 'Delete next line MsgBox "Save routine running" End Sub Sub DoSave() If ActiveDocument.Saved = False Then ActiveDocument.Save End If SaveTime End Sub

How to use:

  1. Save the attachment in your templates folder
  2. or
  3. Paste the relevant sections of code into ThisDocument and Standard modules as indicated.
 

Test the code:

  1. Open a new document based on the template.
  2. The annoying message box is for demo purposes and can be deleted.
 

Sample File:

DoSave.zip 5.84KB 

Approved by mdmackillop


This entry has been viewed 111 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express