Duplicate Row in Word Table

W

Workaholic

Hi,

I am running Word Automation (Word 2003) within an application to
drive changes to Word documents. As part of this application, I need
to be able to duplicate table rows. Adding a blank row is
insufficient, as the table rows may have specific formatting (and
text) within each cell, that
all need to be duplicated. I am currently using cut-and-paste, which
is working, but is dangerous as any other changes made to the
clipboard on the PC can affect the process.

Is there a way to duplicate rows within Word tables, but without using
cut-and-paste?

Thanks
 
H

Helmut Weber

Hi Workaholic,

there must be better solutions than that one,
but as long as they aren't there...

Sub Macro4()
Dim oTbl As Table
Dim r1 As Range
Dim y As Long
Set oTbl = Selection.Tables(1)
y = Selection.Cells(1).RowIndex
Set r1 = Selection.Rows(1).Range.FormattedText
Selection.InsertRowsBelow 1
Selection.Rows(1).Range.FormattedText = _
r1.FormattedText
'which creates a new blank row (?), therefore
oTbl.Rows(y + 2).Delete
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top