Saving a document in multiple locations at one time.

F

FC

I would like to be able to save a single document in multiple folders at one
time. So I guess that means all these folders must be linked.
Thanks
 
K

Kevin B

The folder do not have to be linked, you just need to loop through all the
paths you want to save to. The code below saves a file to 4 different
directories:

Sub MultiSave()

Dim doc As Document
Dim strFolder1 As String
Dim strFolder2 As String
Dim strFolder3 As String
Dim strFolder4 As String
Dim varArray As Variant
Dim varFolders As Variant

Set doc = ActiveDocument
strFolder1 = "d:\FullPath1"
strFolder2 = "d:\FullPath2"
strFolder3 = "d:\FullPath3"
strFolder4 = "d:\FullPath4"

varArray = Array(strFolder1, strFolder2, strFolder3, strFolder4)
varFolders = varArray

Application.DisplayAlerts = wdAlertsNone

For Each varFolders In varArray
doc.SaveAs varFolders & "\" & "DocumentName.doc"
Next varFolders

Application.DisplayAlerts = wdAlertsAll
Set doc = Nothing
 
F

FC

Thanks for the reply,
I am new to programming and so I am not sure where I should write this
routine in . Your help is appreciated.
Fc
 
K

Kevin B

Access the Visual Basic editor using any of the following methods:

1. Press Alt+F11
2. Click Tools in the menu, Macro from the drop-down menu and VB Editor
3. Right click on any toolbar, select the VB toolbar and click the VB
editor button

Once you're in the editor click Insert and select module, and this is where
you would enter in any code.

FYI: In my prior post I neglected to copy the End Sub line, which should be
the last line in the macro.

You can copy the code out of the post and substitute the correct paths and
filename if you want to test drive the code. To execute the code from the
Editor press F5, or to run the code 1 line at a time press F8, once for each
line of code in the sub.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top