07-30-2017
10:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-30-2017
10:27 PM
Here's the code with a document check to prevent an attempt to save closed document.
It will keep reseting until you (re)open new(another) document.
Sub Main()
Dim Thread1 As New System.Threading.Thread(AddressOf AutoSave)
Thread1.Start()
End Sub
Sub AutoSave()
Dim AST As Integer = 0
While True
If ThisDoc IsNot Nothing Then
If AST >= 15 Then '15 minutes
AST = 0
Dim SF As DialogResult = MessageBox.Show("Do you want to save?", "Autosave", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If SF = vbYes And ThisDoc IsNot Nothing Then
ThisDoc.Save()
End If
Else
AST += 1
End If
Else
AST = 0
End If
System.Threading.Thread.Sleep(60000) '1 minute = 60000 ms
End While
End Sub
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods