![]() |
#1
|
|||
|
|||
![]()
Hi all, I have the code that help me find multiple texts in word table.
1. Data from excel => convert to word document(name A) (each cell value is 1 paragraph) 2. VBA in word (the main document B- only has 1 table) a. open VBA in document B (this will open document A) b. find all item from document A in document B c. The code works fine until here. d. for the found items in table (document B); select the whole row and paste in the new table or new document (i need help with this portion) Sub FindMultiItemsInDoc() Dim objListDoc As Document Dim objTargetDoc As Document Dim objParaRange As Range, objFoundRange As Range Dim objParagraph As Paragraph Dim strFileName As String strFileName = InputBox("Enter the full name of the list document here:") Set objTargetDoc = ActiveDocument Set objListDoc = Documents.Open(strFileName) objTargetDoc.Activate For Each objParagraph In objListDoc.Paragraphs Set objParaRange = objParagraph.Range objParaRange.End = objParaRange.End - 1 With Selection .HomeKey Unit:=wdStory ' Find target items. With Selection.Find .ClearFormatting .Text = objParaRange .MatchWholeWord = True .MatchCase = False .Execute End With Next objParagraph End Sub |
Tags |
vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
tbrynard01 | Word VBA | 3 | 11-12-2020 02:06 PM |
![]() |
fly545 | Word VBA | 11 | 01-16-2020 05:53 PM |
Looking to copy select cells in table using dropdown list to paste to new table in another worksheet | CaptainRetired | Excel Programming | 18 | 01-04-2018 07:22 PM |
![]() |
Joey Cheung | Word Tables | 1 | 08-12-2014 05:15 PM |
Copy and paste table | Patrickjm | Word | 1 | 03-19-2013 03:30 PM |