Thread: Auto-save macro
View Single Post
 
Old 07-24-2018, 04:16 PM
brent chadwick brent chadwick is offline Windows 8 Office 2013
Advanced Beginner
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default Auto-save macro

Hey Guys,
Got this macro somewhere and it works good in a docm. but I want it to work in a dotm. Tried everything I know, not working. here's the code for the macro-


Code:
                   Option Explicit
  Private Const mlngTimeout As Long = 5*60
  Public gsngStartTime As Single
  Private msngElapsed As Single
   
  Public Sub AutoSave()
  msngElapsed = Timer - gsngStartTime
  If ThisDocument.Saved = True Then
  gsngStartTime = Timer
  ElseIf msngElapsed >= mlngTimeout Then
  ThisDocument.Save
  MsgBox "Remember to save your work regularly."
  gsngStartTime = Timer
  End If
  Application.OnTime When:=Now + TimeValue("00:00:10"), Name:="Project.Module1.AutoSave"
  End Sub
Here's what goes in the document-




Code:
 Private Sub Document_Open()
  gsngStartTime = Timer
  Application.OnTime When:=Now + TimeValue("00:00:10"), Name:="Project.Module1.AutoSave"
  End Sub
Any suggestions?
Reply With Quote