![]() |
#2
|
||||
|
||||
![]()
Try the following. It assumes:
• you have a word list in another document, with each word/expression you want to find separated by paragraph breaks; • the document to be processed in the active document; and • a new document is to be created for the output. Code:
Sub CreateSummary() Application.ScreenUpdating = False Dim FRDoc As Document, SrcDoc As Document, RsltDoc As Document, FRList, i As Long, Rng As Range 'Load the strings from the reference doc into a text string to be used as an array. Set SrcDoc = ActiveDocument Set FRDoc = Documents.Open("Drive:\FilePath\ReferenceList.doc") FRList = FRDoc.Range.FormattedText FRDoc.Close False Set FRDoc = Nothing Set RsltDoc = Documents.Add 'Process each string from the reference doc For i = 0 To UBound(Split(FRList, vbCr)) - 1 With SrcDoc.Range With .Find .ClearFormatting .Replacement.ClearFormatting .MatchWholeWord = True .MatchCase = True .Wrap = wdFindStop .Text = Split(FRList, vbCr)(i) .Execute End With Do While .Find.Found Set Rng = RsltDoc.Characters.Last Rng.Collapse wdCollapseStart Rng.FormattedText = .Duplicate.Paragraphs.First.Range.FormattedText .Collapse wdCollapseEnd .Find.Execute Loop End With Next Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
dharani suresh | Excel Programming | 5 | 04-29-2014 03:25 AM |
Search and replace/insert HTML code into Master File using tags | dave8555 | Excel | 2 | 02-23-2014 03:51 PM |
![]() |
anacond11 | Word | 2 | 08-08-2013 08:10 AM |
How do I search for terms in initial upper-case? | bertietheblue | Word | 5 | 05-02-2012 05:24 AM |
Modify vba code to print based on name in the InputBox | OTPM | Project | 0 | 05-25-2011 02:03 AM |