auto backup Word file periodically

Blanchec

Bit poster
Hello.

I know that I can backup Word files when saving and closing your file by checking "Always create backup copy" box in Word Options.
But can I make it auto backup periodically ? For example, every 5 minutes when I'm editing the file . It will much more safer to me. Any help will be appreciated.
 
Hi @Blanchec , there is not option in Microsoft Word to back up periodically, however please check with Microsoft office support and check if they have any alternate work around for this.
 
Hi,Blanchec

For that , maybe you can write VBA codes to do that for you. Here is a sample you can try.

Code:
Sub AutoOpen()
  Dim strBackupPath As String
  nReturnValue = MsgBox("Do you want to open AutoBackupDocument?", 4, "Auto Backup Document")
  If nReturnValue = 6 Then
    Call AutoBackupDocument
  End If

End Sub

Sub AutoBackupDocument()
  Dim dtNewBackupTime As Date
  Dim strFilePath, strFileName As String
  Dim strFileFormate As String

  strFileFormat = Right(ActiveDocument.Name, 4)
  If StrComp(strFileFormat, ".doc", vbTextCompare) = 0 Then
    dtNewBackupTime = Now + TimeValue("00:05:00") ' Change the "00:05:00" to the real backup interval time you want.
    strFilePath = ActiveDocument.Path
    strFileName = Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4)
    ChangeFileOpenDirectory strFilePath
    ActiveDocument.SaveAs FileName:="C:\Users\Public\Documents\New folder\Test2\" & strFileName & "_backup.doc", ReadOnlyRecommended:=True ' Change the "C:\Users\Public\Documents\New folder\Test2\" as the real path which you need to put the backup file.
    ActiveDocument.SaveAs FileName:=strFileName & ".doc", ReadOnlyRecommended:=False
    Application.OnTime When:=dtNewBackupTime, Name:="AutoBackupDocument"
    CreateObject("Wscript.shell").popup "An new backup:" & strFileName & "_backup.doc", 2, "Auto close this box after 2s"
    Else
    If StrComp(strFileFormat, "docx", vbTextCompare) = 0 Then
      dtNewBackupTime = Now + TimeValue("00:05:00") ' Change the "00:05:00" to the real backup interval time you want.
      strFilePath = ActiveDocument.Path
      strFileName = Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 5)
      ChangeFileOpenDirectory strFilePath
      ActiveDocument.SaveAs FileName:="C:\Users\Public\Documents\New folder\Test2\" & strFileName & "_backup.docx", ReadOnlyRecommended:=True ' Change the "E:\Temp\backup\" as the real path which you need to put the backup file.
      ActiveDocument.SaveAs FileName:=strFileName & ".docx", ReadOnlyRecommended:=False
      Application.OnTime When:=dtNewBackupTime, Name:="AutoBackupDocument"
      CreateObject("Wscript.shell").popup "An new backup:" & strFileName & "_backup.docx", 2, "Auto close this box after 2s"
    End If
  End If
End Sub

You can find more details at

https://www.datanumen.com/blogs/2-quick-ways-auto-back-word-document-periodically/

Good luck.
 
Last edited:
Back
Top