Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2023, 07:27 AM
gmayor's Avatar
gmayor gmayor is offline Copy document to a few places Windows 10 Copy document to a few places Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
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


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
Reply With Quote
Reply



Similar Threads
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
Copy document to a few places Copy selected text from one document and paste to new document in same position on the page 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:17 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