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 / Tables / March 2008

Tip: Looking for answers? Try searching our database.

Tables[1].Rows.Add returns null if table has vertically merged cel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Prasad More - 20 Mar 2008 10:38 GMT
The following line of code in my application insert a new row after the last
row in table.

Row tRow = range.Tables[1].Rows.Add(ref missingValue);

Where
1. tRow is object of Microsoft.Office.Interop.Word.Row class
2. range is object of Microsoft.Office.Interop.Word.Range

This code works fine when table contains no vertically merged cells. If the
table contains vertically merged cells, Rows.Add returns null value.

Any idea "Why Rows.Add returns null when table contains vertically merged
cells"?.

Thanks,
Prasad
Tony Jollans - 20 Mar 2008 11:12 GMT
Why? is a difficult question to answer. It is, however, not possible to
directly address individual rows of tables with vertically merged cells,
even though there may be no merged cells in the row in question.

One workaround would be to address the first cell of the new row and then
expand the range:

   range.Tables(1).Rows.Add
   Set tRow = range.Tables(1).Cell(range.Tables(1).Rows.Count, 1).Range
   tRow.Expand wdRow

(this assumes the row is added at the end of the table)
(this is also VBA so you'll need to tweak it slightly)

Signature

Enjoy,
Tony

> The following line of code in my application insert a new row after the
> last
[quoted text clipped - 15 lines]
> Thanks,
> Prasad
Prasad More - 24 Mar 2008 13:05 GMT
Hi Tony,

   Thank you for reply. The issues that I am facing is I cannot access
individual rows of a table when there are vertically merged cells into it and
the second issue is Add method fails. So when the Add method fails to return
the reference to added row, there is no way I can access first cells and
expand the range.

Best Regards,
Prasad

> Why? is a difficult question to answer. It is, however, not possible to
> directly address individual rows of tables with vertically merged cells,
[quoted text clipped - 29 lines]
> > Thanks,
> > Prasad
Tony Jollans - 24 Mar 2008 20:32 GMT
Sorry, but I don't know why the Add should fail. What error code does it
give?

Signature

Enjoy,
Tony

> Hi Tony,
>
[quoted text clipped - 43 lines]
>> > Thanks,
>> > Prasad
 
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.