![]() |
|
#1
|
|||
|
|||
|
Hi everyone,
I would like to make a macros to extract text within parentheses and all countries names in order of apearence within 2 open word documents and combine them on a new document for revision. I suppose I have to provide the list of countries I have a macro to extract and put on a table text within parentheses but it only works for one document. I want to add extraction of all countries listed in the doc too. and that it processes both open documents. There is no need for autosave since its only for revision. Here the macro for extracting text within parentheses. Sub ExtractText() Dim cDoc As Word.Document, nDoc As Word.Document Dim cRng As Word.Range, nRng As Word.Range Set cDoc = ActiveDocument Set nDoc = Documents.Add Set cRng = cDoc.Content Set nRng = nDoc.Content cRng.Find.ClearFormatting With cRng.Find .Forward = True .Text = "(" .Wrap = wdFindStop .Execute Do While .Found cRng.Collapse Word.WdCollapseDirection.wdCollapseEnd cRng.MoveEndUntil Cset:=")", Count:=Word.wdForward nRng.FormattedText = cRng.FormattedText nRng.InsertParagraphAfter nRng.Collapse Word.WdCollapseDirection.wdCollapseEnd cRng.Collapse Word.WdCollapseDirection.wdCollapseEnd .Execute Loop End With End Sub thanks a lot |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Need macro to make list of "defined terms"
|
glnz | Word VBA | 8 | 09-07-2022 02:09 PM |
| How to extract names from a list | flyoverrunner | Excel | 3 | 06-06-2018 04:54 AM |
Best Practice for Indexing Multiple Word Terms and Sub-Terms
|
jhy001 | Word | 4 | 11-06-2017 02:08 PM |
How to Combine a Table of Contents Page with Another Document
|
Dante49 | Word | 2 | 10-24-2016 01:53 PM |
Need to extract two word domains from a list (BULK)
|
Maxwell314 | Excel | 3 | 12-08-2014 06:17 PM |