View Single Post
 
Old 06-24-2015, 10:05 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
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

While Paul is correct, if you are copying the content of the named document into the active document then the following will do that. You don't have to use the clipboard (though you could).

Code:
Dim oDoc As Document
Dim oSource As Document
Dim oRng As Range
    Set oDoc = ActiveDocument
    Set oSource = Documents.Open(Filename:= _
                                 "X:\sconner\CCD Damage Mechanisms\Mechanisms\Underdeposit Corrosion.docx", _
                                 ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
                                 PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
                                 WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
                                 wdOpenFormatAuto, XMLTransform:="")
    Set oRng = oDoc.Range
    With oRng.Find
        Do While .Execute(FindText:="(NEXT MECH)")
            oRng.FormattedText = oSource.Range.FormattedText
            oRng.Collapse 0
        Loop
    End With
    oSource.Close 0
__________________
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