Word Autosave 1

Credit to datanumen.com

Save reminder will prompt user to name new documents when a blank doc is open, if refused will show number of open unsaved documents. Autosaves named documents every 5 min.

Alt F11 in Word to open the VBA editor, click “Normal” to select the Normal template, and hit Insert –> Module to create a new module.  Paste the following code in the new module and save it.

Sub AutoNew()
  Dim objDoc As Document
  Dim strButtonValue As String
  Dim dtAskingTime As Date
 
  '  Initialization
  Set objDoc = ActiveDocument
  '  Set the asking time in 5 minutes.
  dtAskingTime = Now + TimeValue("00:05:00")
 
  If objDoc.Path <> "" Then
    Exit Sub
  Else
    strButtonValue = MsgBox("This document has not been saved yet." & vbCr & "Do you want to save the file?", vbYesNo)
    If strButtonValue = vbYes Then
      Dialogs(wdDialogFileSaveAs).Show
      '  In case you click Cancel button, the macro continue running and prompting message in every 5 minutes.
      If objDoc.Path = "" Then
        Application.OnTime When:=dtAskingTime, Name:="AutoNew"
      End If
    Else
      Application.OnTime When:=dtAskingTime, Name:="AutoNew"
    End If
  End If
  Call CountUnsavedDoc
End Sub

Sub CountUnsavedDoc()
  Dim objDoc As Document
  Dim nDocUnsaved As Integer
 
  nDocUnsaved = 0

  For Each objDoc In Documents
    If objDoc.Path = "" Then
      nDocUnsaved = nDocUnsaved + 1
    End If
  Next objDoc
  nDocUnsaved = MsgBox(nDocUnsaved, 0, "Number of unsaved document")
End Sub

Leave a Reply