Synchronize saving files into multiple locations?

Is there a way for me to save files in one location, and they are automatically saved in another location?

Basically we have a folder in which we keep backups, and we want to save a word document to our My Documents folder while at the same time the document in the backup folder is saved as well. Thanks in advance for your assistance.
WilliamK99Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GrahamSkanConnect With a Mentor RetiredCommented:
You can do this in VBA.

Put this code in the ThisDocument module of the Normal template.
Option Explicit
Const strBackUpFolder = "C:\MyBackups"
Const strAppName = "Documents"
Const strSecName = "For Backup"
 
Private Sub Document_Close()
    'call back up macro after close
    Application.OnTime DateAdd("s", 1, Now), "BackUpFiles"
End Sub
 
Private Sub BackUpFiles()
    Dim i As Integer
    Dim bClosed As Boolean
    Dim strForBackUp() As String
    Dim strParts() As String
    Dim strFile As String
    Dim v As Variant
    Dim doc As Document
    
    v = GetAllSettings(strAppName, strSecName)
    If Not IsEmpty(v) Then
        strForBackUp = v
        For i = 0 To UBound(strForBackUp)
            strParts = Split(strForBackUp(i, 1), "\")
            strFile = strParts(UBound(strParts))
            bClosed = True
            For Each doc In Documents
                bClosed = True
                If UCase$(doc.Name) = UCase$(strFile) Then
                    bClosed = False
                    Exit For 'not yet closed
                End If
            Next doc
            If bClosed Then
                FileCopy strForBackUp(i, 1), strBackUpFolder & "\" & strFile
                DeleteSetting strAppName, strSecName, strForBackUp(i, 0)
            End If
        Next i
    End If
End Sub
 
Sub FileSave()
    ActiveDocument.Save
    RememberForBackup
End Sub
 
Sub FileSaveAs()
Dim dlg As Dialog
Set dlg = Dialogs(wdDialogFileSaveAs)
    If dlg.Show = -1 Then
        RememberForBackup
    End If
End Sub
Sub RememberForBackup()
    Dim i As Integer
    Dim f As Integer
    Dim strForBackUp() As String
    Dim v As Variant
    
    v = GetAllSettings(strAppName, strSecName)
    If Not IsEmpty(v) Then
        strForBackUp = v
        For i = 0 To UBound(strForBackUp)
            If UCase$(ActiveDocument.Name) = UCase$(strForBackUp(i, 1)) Then
                Exit Sub 'already in list
            End If
            If strForBackUp(i, 0) > f Then
                f = strForBackUp(i, 0) + 1
            End If
        Next i
    End If
    SaveSetting strAppName, strSecName, f, ActiveDocument.Name
 
End Sub

Open in new window

0
 
mullinsbcCommented:
I've never seen a multiple location save capability in any application, which is why I use a batch file to do something similar to what you want.

Essentially you create a .bat file in notepad with the backup (copy) commands you want.  I use XCOPY because it's a little more robust than regular COPY.  You can find all the switches to XCOPY by opening up a DOS screen and typing:

HELP XCOPY

Once you create your batch file, you can set it to automatically run at timed intervals by adding the batch file you created to the Windows Task Scheduler.

More info can be found here:

http://www.ahuka.com/backup/backup4.html



0
All Courses

From novice to tech pro — start learning today.