View Single Post
  #4   Report Post  
Posted to microsoft.public.word.tables
Klaus Linke Klaus Linke is offline
external usenet poster
 
Posts: 413
Default How copy text from one table to insert in another (w/o tbl structu

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


"Doug Robbins - Word MVP" wrote:
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

"mkraft" wrote in message
...
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.