Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-25-2019, 09:42 AM
lleoun lleoun is offline Copy all paragraphs where a particular word or phrase is found in Word 2010 Windows 8 Copy all paragraphs where a particular word or phrase is found in Word 2010 Office 2010
Novice
Copy all paragraphs where a particular word or phrase is found in Word 2010
 
Join Date: Nov 2018
Posts: 5
lleoun is on a distinguished road
Default Copy all paragraphs where a particular word or phrase is found in Word 2010

Hi all,

Is there any way to search for a particular word or phrase in Word 2010 and highlight the entire paragraph where it is found?

I want to copy all the highlighted paragraphs that result from the search and paste them into a new Word 2010 document.



Thank you very much!

Last edited by Charles Kenyon; 09-26-2019 at 10:13 AM. Reason: Change title to give better info about question and mark as solved
Reply With Quote
  #2  
Old 09-25-2019, 01:14 PM
Charles Kenyon Charles Kenyon is offline Copy all paragraphs where a particular word or phrase is found in Word 2010 Windows 10 Copy all paragraphs where a particular word or phrase is found in Word 2010 Office 2016
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,116
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

There are no tools built into Word to accomplish this without macros.
Reply With Quote
  #3  
Old 09-25-2019, 11:39 PM
lleoun lleoun is offline Copy all paragraphs where a particular word or phrase is found in Word 2010 Windows 8 Copy all paragraphs where a particular word or phrase is found in Word 2010 Office 2010
Novice
Copy all paragraphs where a particular word or phrase is found in Word 2010
 
Join Date: Nov 2018
Posts: 5
lleoun is on a distinguished road
Default

thanks for your answer, should I ask the question in the Word VBA forum then?
Thanks again
Reply With Quote
  #4  
Old 09-26-2019, 12:16 AM
gmayor's Avatar
gmayor gmayor is offline Copy all paragraphs where a particular word or phrase is found in Word 2010 Windows 10 Copy all paragraphs where a particular word or phrase is found in Word 2010 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
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 of
Default

I am sure I did something very similar recently, but I cannot spot where I posted it, so the following will work. Change 'Word or phrase' as appropriate.

Code:
Sub Macro1()
Const strFind As String = "Word or phrase" 
Dim oRng As Range, oTargetRng As Range
Dim oSource As Document, oTarget As Document
    Set oSource = ActiveDocument
    Set oTarget = Documents.Add
    Set oRng = oSource.Range
    With oRng.Find
        Do While .Execute(findText:=strFind)
            oRng.Start = oRng.Paragraphs(1).Range.Start
            oRng.End = oRng.Paragraphs(1).Range.End
            'oRng.HighlightColorIndex = wdYellow
            Set oTargetRng = oTarget.Range
            oTargetRng.Collapse 0
            oTargetRng.FormattedText = oRng.FormattedText
            oTargetRng.InsertParagraphAfter
            oRng.Collapse 0
        Loop
    End With
    Set oSource = Nothing: Set oTarget = Nothing
    Set oRng = Nothing: Set oTargetRng = Nothing
End Sub
P.S. Found it - https://www.msofficeforums.com/word-...t-strings.html
__________________
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
  #5  
Old 09-26-2019, 12:52 AM
lleoun lleoun is offline Copy all paragraphs where a particular word or phrase is found in Word 2010 Windows 8 Copy all paragraphs where a particular word or phrase is found in Word 2010 Office 2010
Novice
Copy all paragraphs where a particular word or phrase is found in Word 2010
 
Join Date: Nov 2018
Posts: 5
lleoun is on a distinguished road
Default

whoah!! THANKS A TON!!!
Reply With Quote
Reply

Tags
highligh, search, word 2010

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
reverse order of paragraphs, word 2010 moorea21 Word VBA 1 08-02-2018 03:47 AM
Copy all paragraphs where a particular word or phrase is found in Word 2010 Macro to highlight wildcard phrase, copy and paste into new doc. MaryTom Word VBA 2 05-18-2018 04:23 PM
Copy all paragraphs where a particular word or phrase is found in Word 2010 Macro to hide all paragraphs that do not have the found result jplat Word VBA 1 09-10-2017 09:13 PM
Copy all paragraphs where a particular word or phrase is found in Word 2010 issue with highlight macro word 2010 jamesnavoy Word VBA 2 01-29-2017 08:32 AM
Copy all paragraphs where a particular word or phrase is found in Word 2010 Macro to highlight text between 2 points in word 2010 jsilva1950 Word VBA 2 04-25-2013 12:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft