Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Copy a row inside an other table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex St-Pierre - 18 Mar 2008 14:29 GMT
Hi!
I split a table into a lot of pages using macro and I would like to
copy-paste the first row of table#1 at the top of table #2, etc.
Something like the following but using the object method.
Thank you!
Alex
docWord.Tables(2).Rows.Add BeforeRow:=oRange.Tables(2).Rows(1)
docWord.Tables(1).Rows(1).Range.Select
Selection.Copy
docWord.Tables(2).Rows(1).Range.Select
Selection.Paste 'Gives error 438..

Signature

Alex St-Pierre

Jean-Guy Marcil - 18 Mar 2008 15:00 GMT
> Hi!
> I split a table into a lot of pages using macro and I would like to
[quoted text clipped - 7 lines]
> docWord.Tables(2).Rows(1).Range.Select
> Selection.Paste 'Gives error 438..

Try something like this:

Dim tblPaste As Table
Dim i As Long
Dim rowCopy As Row

With ActiveDocument
   Set rowCopy = .Tables(1).Rows(1)
   For i = 2 To .Tables.Count
       With .Tables(i)
           .Rows.Add (.Rows(1))
           .Rows(1).Range.FormattedText = rowCopy.Range.FormattedText
           .Rows(2).Delete
       End With
   Next
End With
Alex St-Pierre - 18 Mar 2008 16:14 GMT
Thank's a lot. It works very well.
I'm wondering if there are 2 rows to copy from table #1 to table #2 (first
two row), is it possible to copy the 2 rows at the same time by setting
rowCopy equal to the first two rows?
Alex
Signature

Alex St-Pierre

> > Hi!
> > I split a table into a lot of pages using macro and I would like to
[quoted text clipped - 24 lines]
>     Next
> End With
Jean-Guy Marcil - 18 Mar 2008 17:29 GMT
> Thank's a lot. It works very well.
> I'm wondering if there are 2 rows to copy from table #1 to table #2 (first
> two row), is it possible to copy the 2 rows at the same time by setting
> rowCopy equal to the first two rows?

Modify the code I posted and try it! You would probably need two row
objects... Or try without row objects and use the Range object instead...

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.