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 / December 2004

Tip: Looking for answers? Try searching our database.

GET ROW COUNT OF A TABLE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dipali - 25 Nov 2004 11:19 GMT
I have a table with cells merged together.some cells are having row spans as
well as col spans

now i want to navigate through the table and find out value in each cell of
the table.I am doing this by two for loops first one increments row number
and second one increments column number.This code is working fine if any of
the cells have not merged with other cell.

If i merge some of the cells then this code gives error saying can not
access individual rows since there are vertically merged cells.

Do you have solution for this problem?
Jonathan West - 25 Nov 2004 12:18 GMT
>I have a table with cells merged together.some cells are having row spans
>as
[quoted text clipped - 11 lines]
>
> Do you have solution for this problem?

This code example will show you how to cope

Sub SetCellNumbers()
Dim oCell As Cell
For Each oCell In ActiveDocument.Tables(1).Range.Cells
 oCell.Range.InsertAfter oCell.RowIndex & " " & oCell.ColumnIndex
Next oCell
End Sub

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

Helmut Weber - 25 Nov 2004 13:09 GMT
Hi,
you can still loop through all cells like this,
Dim oCll As Cell
With ActiveDocument.Tables(1).Range
  For Each oCll In .Cells
     oCll.Select
  Next
End With
or use for i = 1 to ActiveDocument.Tables(1).Range.Cells.Count
You also can access r (row) and c (col) of the given cell:
     r = oCll.RowIndex
     c = oCll.ColumnIndex
If you have merged cells (1,2) and (2,2) vertically,
then cell(2,2) has vanished. Though, with horizontally merged cells,
this method doesn't work, and I wonder, if there is a solution at all.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Jezebel - 28 Dec 2004 05:27 GMT
And for a third method of iterating all the cells in a table --

Dim pCell as Word.Cell

Set pCell = Selection.Tables(1).Cell(1,1)            'This cell always
exists, whatever merging or splitting you might have done

Do
   .... work with pCell

   set pCell = pCell.Next
Loop until pCell is nothing

> I have a table with cells merged together.some cells are having row spans as
> well as col spans
[quoted text clipped - 8 lines]
>
> Do you have solution for this problem?
 
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.