Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2016, 05:40 AM
gmayor's Avatar
gmayor gmayor is offline Copying paragraphs from multiple documents to the current one. Windows 10 Copying paragraphs from multiple documents to the current one. Office 2016
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

If you copy and paste the texts, that will clear the original clipboard content so the short answer is no. However it would be possible to search a batch of documents for a particular text string and reproduce the paragraphs containing that text in the current document, without the need to copy and paste e.g.
Code:
Option Explicit

Sub Copy_Paras()
Dim strPath As String
Dim strFilename As String
Dim oTarget As Document
Dim oDoc As Document
Dim oRng As Range
Dim oRng2 As Range
Dim strText As String

    Set oTarget = ActiveDocument
    Set oRng2 = Selection.Range
    strText = InputBox("Enter the text to find")
    If strText = "" Then GoTo lbl_Exit
    strPath = "C:\Path\"        'The folder with the documents

    strFilename = Dir$(strPath & "*.docx")
    While Len(strFilename) <> 0
        Set oDoc = Documents.Open(strPath & strFilename)
        Set oRng = oDoc.Range
        With oRng.Find
            Do While .Execute(FindText:=strText)
                oRng2.Text = oRng.Paragraphs(1).Range.Text
            Loop
        End With
        oDoc.Close SaveChanges:=0
        strFilename = Dir$()
        DoEvents
    Wend
lbl_Exit:
    Set oRng = Nothing
    Set oRng2 = Nothing
    Set oDoc = Nothing
    Set oTarget = Nothing
    Exit Sub
End Sub

__________________
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
Copying tables between Word documents FIN Word 1 02-10-2015 05:59 PM
Copying Selected Text Between Word Documents Iluvatar343 Word VBA 1 06-05-2014 05:15 AM
Copying paragraphs from multiple documents to the current one. Find and Replace multiple lines/paragraphs jcw Word 1 11-18-2011 11:47 AM
Copying paragraphs from multiple documents to the current one. MS Excel 2004 for Mac - copying dates between documents BCRenton Excel 4 11-10-2009 07:28 AM
Copying tables between Word documents best practices? dylane Word Tables 0 12-18-2008 12:21 PM

Other Forums: Access Forums

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