How copy text from one table to insert in another (w/o tbl structu

M

mkraft

I wanted to copy data from one table to another with the same table structure
(same number of rows/columns).

When I selected and copied the text from the first table and then inserted
it into the other, the entire table structure was included in the copy.

How can I prevent that -- i.e., how can I get only the text to insert into
the target table?

Thanks.
 
M

mkraft

I just want to clarify that I meant that the 2 tables had the same
'structure' from the get-go and that I wanted simply to transfer 'text' from
the second to the first.

My problem was that I could not find a way to transfer *only* the text.
When I inserted what I thought was only text in the second table, all the
table structure from the first table was also inserted along with it --
making a mess.
 
D

Doug Robbins - Word MVP

The following code in a macro will copy the content from the first table in
a document to the second table:

Dim Source As Table, Target As Table
Dim i As Long, j As Long
Dim crange As Range
Set Source = ActiveDocument.Tables(1)
Set Target = ActiveDocument.Tables(2)
With Source
For i = 1 To .Rows.Count
For j = 1 To .Columns.Count
Set crange = .Cell(i, j).Range
crange.End = crange.End - 1
Target.Cell(i, j).Range.Text = crange.Text
Next j
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
K

Klaus Linke

Or if you copied say 2×3 cells to the clipboard, you'd need to select 2×3
cells first before you paste into the new table (... and create the new
cells beforehand if necessary).
Haven't tried it now, but that has worked for me in the past, and it is a
bit faster than transferring the individual cell contents.

Regards,
Klaus
 
S

Suzanne S. Barnhill

I find that this works well pasting from Excel to Word but often fails
pasting Word to Word. Go figure.
 

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