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 / August 2005

Tip: Looking for answers? Try searching our database.

Insert Row Beneath Last Row in Table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andibevan - 16 Aug 2005 09:30 GMT
Hi There,

I have some code that I have to run from within Excel.  I have worked out
how to locate a table and then manipulate the contents, but I can't work-out
how to insert a new row below the last row of the table?

Thanks

Andy
Helmut Weber - 16 Aug 2005 09:54 GMT
Hi,

like this:

ActiveDocument.Tables(1).Rows.Add

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Andibevan - 16 Aug 2005 10:12 GMT
Thanks Helmut - How do I then refer to the cells within this last row?

Alternatively - what method do I use to return /determine the last row of a
table?

> Hi,
>
[quoted text clipped - 6 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
Helmut Weber - 16 Aug 2005 10:37 GMT
Hi,

just one of some ways:

With ActiveDocument.Tables(3).Rows.Last
  MsgBox Len(.Cells(2).Range.Text)
End With

I hope, the use of "activedocument" doesn't confuse you.
You have do adapt the code to work from Excel.

An note that ...cells(2).range.text contains
not only the text in that cell, but the two
characters, that make up the end-of-cell mark,
in addition.

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Andibevan - 16 Aug 2005 10:52 GMT
Thanks Helmut - I have used vba in excel loads but never had a requirement
within Word before.  Do you know if the Rows.Last method works when
controlling word from within excel?

> Hi,
>
[quoted text clipped - 16 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
JBNewsGroup - 16 Aug 2005 10:51 GMT
Hi Andibevan,

The last row would be the number of rows:

ActiveDocument.Tables(1).Rows.Count

You could then set a Range to that row.

Jerry Bodoff

> Thanks Helmut - How do I then refer to the cells within this last row?
>
[quoted text clipped - 11 lines]
> > "red.sys" & chr(64) & "t-online.de"
> > Word 2002, Windows 2000
Doug Robbins - 16 Aug 2005 18:11 GMT
Dim newrow as Row
Set newrow = ActiveDocument.Tables(1).Rows.Add

newrow now can be used to refer to the row that you just added.

Signature

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

> Thanks Helmut - How do I then refer to the cells within this last row?
>
[quoted text clipped - 12 lines]
>> "red.sys" & chr(64) & "t-online.de"
>> Word 2002, Windows 2000
 
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.