#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
Cross-posted at: vba - Copy row and paste to new table - Stack Overflow
For cross-posting etiquette, please read: A message to forum cross posters - Excelguru Also, when posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
vba |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro in Word to copy and paste a row to add to a table | tbrynard01 | Word VBA | 3 | 11-12-2020 02:06 PM |
Want to copy & paste a table underneath itself x no. of time, table found through style heading name | 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 |
Is it possible to copy non-contiguous rows of a Table and paste them as a separate Table in Word? | Joey Cheung | Word Tables | 1 | 08-12-2014 05:15 PM |
Copy and paste table | Patrickjm | Word | 1 | 03-19-2013 03:30 PM |