![]() |
|
#1
|
||||
|
||||
![]() Try the following: Code:
Sub FileCopyTo() Dim sName As String, sOriginal As String Dim vPath() As Variant Dim i As Integer vPath = Array("C:\My doc\", "F:\My doc\", "G:\My doc\", "H:\My doc\") ActiveDocument.Save sOriginal = ActiveDocument.FullName sName = ActiveDocument.Name For i = 0 To UBound(vPath) If FolderExists(CStr(vPath(i))) Then ActiveDocument.SaveAs2 FileName:=CStr(vPath(i)) & sName, FileFormat:=wdFormatXMLDocument End If Next i ActiveDocument.SaveAs2 FileName:=sOriginal, FileFormat:=wdFormatXMLDocument End Sub Private Function FolderExists(strFolderName As String) As Boolean 'Graham Mayor 'strFolderName is the name of folder to check Dim FSO As Object Set FSO = CreateObject("Scripting.FileSystemObject") If (FSO.FolderExists(strFolderName)) Then FolderExists = True Else FolderExists = False End If lbl_Exit: Set FSO = Nothing Exit Function End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inserting text fragments in multiple places of document (Word 2007). | fieloryb | Word | 3 | 05-16-2023 11:10 PM |
Copy a selected range of a document to a new document with preserving formatting,header and footer | RobertDany | Word VBA | 10 | 08-10-2021 04:04 AM |
![]() |
gasparik | Word VBA | 1 | 05-11-2020 05:41 AM |
Need to Selectively Merge Records to Different Places in a Word Directory-type Document | TotheMoonAlice | Mail Merge | 3 | 03-27-2015 08:11 AM |
in 2013, cannot format 4 dec places in Word Document | Abacus1234 | Mail Merge | 3 | 10-23-2013 03:57 PM |