Display first row of table on each page when the table contains merged cells

S

Steve

I know how to set the first row of a table to display on each page
using VBA - "Tables(1).Rows(1).HeadingFormat = True"


....but if there are merged cells in the table, I get error 5991 -
"Cannot access individual rows in this collection because the table has

vertically merged cells"


Does anyone know of a workaround?


I am pulling an HTML table into the word doc automatically (using VB6)
and need to set the HeadingFormat. I have no idea if the table will
have merged cells or not.


steve
 
A

Astrid

Hi Steve,

Try something like this:

-----------------------------------------------------------------------------------------------------
Dim oTable As Table
Dim oCell As Cell

Set oTable = ActiveDocument.Tables(1)
For Each oCell In oTable.Range.Cells
If oCell.Range.Information(wdEndOfRangeRowNumber) = 1 Then
oCell.Range.Rows.HeadingFormat = True
Exit Sub
End If
Next

Set oCell = Nothing
Set oTable = Nothing
-----------------------------------------------------------------------------------------------------

Hope this helps,
regards,
Astrid

So that all can benefit from the discussion, please post all follow-ups to
the newsgroup.
Visit the MVP Word FAQ site at http://www.mvps.org/word/
 

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