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