genespos
genespos

Reputation: 3311

Copy row from a table of a word document and paste it to the end of a table in another word document

In the below code: mWrdTbl is an object containing the table of the 1st word document adWrdTbl is an object containing the table of the 2nd word document (both documents are opened)

mWrdTbl.Rows(R).Range.Copy
adWrdTbl.Range.PasteAppendTable

The code works but the row is pasted at the top of the table (I need it at the end)

Edit:

I found a workaround (but I'm not satisfied):

mWrdTbl.Rows(R).Range.Copy
adWrdTbl.Rows.Add
adWrdTbl.Rows.Add
adWrdTbl.Rows(adWrdTbl.Rows.Count - 1).Range.PasteAppendTable
adWrdTbl.Rows(adWrdTbl.Rows.Count).Delete
adWrdTbl.Rows(adWrdTbl.Rows.Count).Delete

Upvotes: 0

Views: 666

Answers (1)

freeflow
freeflow

Reputation: 4355

This works for me

Dim myRange As Word.Range
Set myRange = adWrdTbl.Range
myRange.Collapse direction:=wdCollapseEnd
myRange.FormattedText = mWrdTbl.Range.Rows(R).Range.FormattedText

Upvotes: 1

Related Questions