Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-24-2018, 04:16 PM
brent chadwick brent chadwick is offline Auto-save macro Windows 8 Auto-save macro Office 2013
Advanced Beginner
Auto-save macro
 
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
  #2  
Old 07-25-2018, 08:04 PM
gmayor's Avatar
gmayor gmayor is offline Auto-save macro Windows 10 Auto-save macro Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,103
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Without lookiing at the metits of the code, did you try changing Document_Open to Document_New given that you don't open templates to use them? Or you could simply use http://www.gmayor.com/automatically_backup.htm which will work with all your documents.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-save macro Macro to auto-save pdf using text on page + current date hysterical.useless Word VBA 12 02-05-2018 02:17 PM
Auto-save macro Auto save macro brent chadwick Word VBA 10 10-25-2017 08:26 AM
Auto-save macro Macro to save as pdf with ability to choose save as folder rvessio Word VBA 4 07-25-2016 12:37 PM
Auto-save macro Auto save has done dark - does not work for me bitraker Word 1 12-28-2015 09:40 AM
Auto-save macro Auto correct will not save shewoman Word 4 10-28-2015 03:51 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:28 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft