Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-04-2022, 12:24 AM
Bikram Bikram is offline Automatically saving document after each 5 minutes Windows 10 Automatically saving document after each 5 minutes Office 2007
Advanced Beginner
Automatically saving document after each 5 minutes
 
Join Date: Jul 2021
Location: Nepal
Posts: 94
Bikram is on a distinguished road
Default Automatically saving document after each 5 minutes

Greetings, I was trying to save my documents if the document was not saved for more than five minutes. I went this far but it is not dynamic enough. How can this be modified to get the job done? Thanks in advance!!


Code:
Function lastsavetime(de As Boolean)
Dim bb As String, curt As Date, curr, intt As Integer, inttt As Integer, last As Date

curt = Now()

    intt = InStr(1, curt, ":")
    curr = Mid(curt, intt + 1, 2)
    last = ActiveDocument.BuiltInDocumentProperties("Last Save Time")
    inttt = InStr(1, last, ":")
    bb = Mid(ActiveDocument.BuiltInDocumentProperties("Last Save Time"), intt + 1, 2)
        If CInt(bb) - CInt(curr) >= 5 Then
            de = True
        End If

End Function
Reply With Quote
  #2  
Old 11-04-2022, 06:07 AM
gmaxey gmaxey is offline Automatically saving document after each 5 minutes Windows 10 Automatically saving document after each 5 minutes Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub SaveMe()
Application.DisplayAlerts = False
ActiveDocument.Save
Application.DisplayAlerts = True
Application.OnTime Now + TimeValue("00:05:00"), "SaveMe"
MsgBox "Saved"
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 11-04-2022, 07:16 AM
gmayor's Avatar
gmayor gmayor is offline Automatically saving document after each 5 minutes Windows 10 Automatically saving document after each 5 minutes Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,135
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 ofgmayor has much to be proud of
Default

See also Automatically save Word Documents and Excel Workbooks. You can set your own time span for the current document or all 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
  #4  
Old 11-06-2022, 03:10 AM
Bikram Bikram is offline Automatically saving document after each 5 minutes Windows 10 Automatically saving document after each 5 minutes Office 2007
Advanced Beginner
Automatically saving document after each 5 minutes
 
Join Date: Jul 2021
Location: Nepal
Posts: 94
Bikram is on a distinguished road
Default

Thank you both gmaxey and gmayor for your help.
Reply With Quote
  #5  
Old 11-07-2022, 07:15 AM
johndanaher johndanaher is offline Automatically saving document after each 5 minutes Windows 10 Automatically saving document after each 5 minutes Office 2021
Novice
 
Join Date: Nov 2022
Posts: 2
johndanaher is on a distinguished road
Default

Would you be able to add a vba code that auto save in the second location every 1 hour. Basically creating backup.


Thank you for sharing the code. I really appreciate how this gets me a leap away from slaving to Microsoft Onedrive autosave
Reply With Quote
  #6  
Old 11-07-2022, 10:02 PM
gmayor's Avatar
gmayor gmayor is offline Automatically saving document after each 5 minutes Windows 10 Automatically saving document after each 5 minutes Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,135
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 ofgmayor has much to be proud of
Default

If you look in the link I posted, the save in two places function in conjunction with the autosave will allow you to do this.
__________________
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
  #7  
Old 11-07-2022, 10:17 PM
Bikram Bikram is offline Automatically saving document after each 5 minutes Windows 10 Automatically saving document after each 5 minutes Office 2007
Advanced Beginner
Automatically saving document after each 5 minutes
 
Join Date: Jul 2021
Location: Nepal
Posts: 94
Bikram is on a distinguished road
Default

You could use the following code:
Code:
Sub ActiveDocument_Save()
Application.OnTime Now + TimeValue("00:05:00"), "Savedoc"
Application.OnTime Now + TimeValue("01:00:00"), "Backupfile"
End Sub
Sub Savedoc()
ActiveDocument.Save
Application.OnTime Now + TimeValue("00:05:00"), "Savedoc"
End Sub
Sub Backupfile()
Dim str, name As String
    With ActiveDocument
        str = ActiveDocument.FullName
        name = ActiveDocument.name
        .Bookmarks.Add "CursorPosition", Selection.Range
        .Save
        .Close
        FileCopy str, "D:\Your Desired Location\" & name
        Application.OnTime Now + TimeValue("01:00:00"), "Backupfile"
        Documents.Open str
        ActiveDocument.Bookmarks("CursorPosition").Select
    End With
End Sub
Or you can use gmayor's code which I used to write the above code:
Code:
Sub SaveACopyToFlash()
Dim strFileA As String
Dim strFlash As String
    strFlash = "D"
    If strFlash = "" Then
        MsgBox "User Cancelled", vbExclamation, "Cancelled"
        Exit Sub
    End If
    With ActiveDocument
        .Save 'save the original document
        strFileA = .FullName 'Saved original document name
        strFlash = strFlash & "\" & .name 'Flash drive filename
        .Close 'Close the document
    End With
    On Error GoTo oops 'Error handler for missing flash drive
    FileCopy strFileA, strFlash 'Copy source to flash
    Documents.Open strFileA
    ActiveWindow.View.Type = wdPrintView
    End
    oops:
    If Err.Number = 61 Then
        MsgBox "Disc Full! The partial file created will be deleted", vbExclamation
        Kill strFlash 'Remove the partial file
    Else
        MsgBox "The flash drive is not available", vbExclamation
    End If
        Documents.Open strFileA
        ActiveWindow.View.Type = wdPrintView
End Sub
Reply With Quote
  #8  
Old 11-07-2022, 10:20 PM
johndanaher johndanaher is offline Automatically saving document after each 5 minutes Windows 10 Automatically saving document after each 5 minutes Office 2021
Novice
 
Join Date: Nov 2022
Posts: 2
johndanaher is on a distinguished road
Default

Thank you. This means a lot. I haven't seen this amount of Internet Magic for a while already!


I am so excited to get rid of Onedrive from my home device!!!
Reply With Quote
Reply

Tags
vba autosave document



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically saving document after each 5 minutes Viewable page automatically shifts after minutes ZenHiker Word 1 10-22-2016 01:40 PM
Word is saving open document automatically in its own, Jamal NUMAN Word 4 10-21-2016 01:37 PM
Automatically saving document after each 5 minutes Saving Attachment Automatically emmanpelayo Outlook 5 09-28-2016 04:17 AM
Outlook is continuously & automatically opening (currently 8 screens in 10 minutes) mikef Outlook 0 07-21-2014 01:49 PM
Word 2010 not saving automatically darrylmarshall Word 1 06-07-2012 02:36 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:54 PM.


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