determine a merged cell span column value

A

alfonso gonzales

Hello Everybody

I have set out to create a simple macro that converts Word tables to HTML
format.

I was albe to do it for tables with regular column and row numbers, but I
have come upon a stumbling block when trying to tacke merged cells ...
these are really a drag!

Looking for a hint on how determine how many columns (or rows) a merged cell
spans.

When saving a word doc as HTML tables are saved correctly, so I guess there
must be a way.

Is there anyone who has undertaken this arduous task and has come
victorious.

alfonso gonzales
 
J

Jezebel

The RowIndex and ColumnIndex properties provide the information you need,
although as you observe, it can get *very* complex, particularly if there
are cells merged vertically as well as horizontally, and if there are split
cells as well.

As a general approach --

1. Iterate the table to find the cell with the highest ColumnIndex value --
this determines the number of columns needed for the HTML table. (It might
be higher than the number of columns Word thinks is in the table, if there
are split cells.)

2. To check for horizontal merging, compare cell with cell.next -- if the
same rowindex then the number of horizontal cells merged into the first is
Cell2.ColumnIndex - Cell1.ColumnIndex; if not in the same row, then merge =
Column Count - ColumnIndex + 1

3. To Check for vertical merging, find the next cell with the same
ColumnIndex value, then compare the rowindex values.
 

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