Copy row in word table and paste to the new table
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
|