Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-26-2022, 12:31 PM
thiennguyen93 thiennguyen93 is offline Copy row in word table and paste to the new table Windows 10 Copy row in word table and paste to the new table Office 2010
Novice
Copy row in word table and paste to the new table
 
Join Date: Jul 2022
Posts: 6
thiennguyen93 is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 07-26-2022, 04:20 PM
macropod's Avatar
macropod macropod is offline Copy row in word table and paste to the new table Windows 10 Copy row in word table and paste to the new table Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

Tags
vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy row in word table and paste to the new table Macro in Word to copy and paste a row to add to a table tbrynard01 Word VBA 3 11-12-2020 02:06 PM
Copy row in word table and paste to the new table 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
Copy row in word table and paste to the new table 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft