Copy Table to End of Document

S

Sonny Maou

after i do

activedocument.tables(1).range.copy

how should i go about pasting it to the end of the document?

Is there a better/faster way to copy a table to the end of the document?

Thanks!!
 
H

Helmut Weber

Hi Sonny,
have a look at this one:
Sub Test556()
Dim oDcm As Range
Set oDcm = ActiveDocument.Range
oDcm.Tables(1).Range.Copy
oDcm.Collapse direction:=wdCollapseEnd
oDcm.Paste
End Sub
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 
J

Jay Freedman

Sonny said:
after i do

activedocument.tables(1).range.copy

how should i go about pasting it to the end of the document?

Is there a better/faster way to copy a table to the end of the
document?

Thanks!!

Hi Sonny,

If you use the Copy method, it goes like this:

ActiveDocument.Tables(1).Range.Copy
Selection.EndKey unit:=wdStory
Selection.Paste

I don't care for that method, for two reasons: (1) If you had something on
the clipboard that you wanted to keep, it's replaced by the table, and (2)
it moves the cursor to the end of the document.

A better method IMHO is to use a Range object collapsed to the end of the
document, and just assign the table's .FormattedText to it:

Dim oRg As Range
Set oRg = ActiveDocument.Range
oRg.Collapse wdCollapseEnd
oRg.FormattedText = _
ActiveDocument.Tables(1).Range.FormattedText
 
S

Sonny Maou

A better method IMHO is to use a Range object collapsed to the end of the
document, and just assign the table's .FormattedText to it:

Dim oRg As Range
Set oRg = ActiveDocument.Range
oRg.Collapse wdCollapseEnd
oRg.FormattedText = _
ActiveDocument.Tables(1).Range.FormattedText

Exactly what I was looking for... Thanks Jay.

(And thanks Helmut for your input, too! :) )
 

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