Enumerating merged cells in MSWord automation

A

Andrey Dzizenko

Hello there!

Explain me please how should I enumerate all cells in a MSWord's table
(using automation of course). There're merged cells in a table, something
like that:

┌──────┬────────â”
│ │ │
│ ├────────┤
│ │ │
├──────┴────────┤
│ │
└───────────────┘

If I try to get access to the cell (2,1), I have an exception.
If I try to get (1,1), it looks like it's not a part of a merged cell.
E.g. it has height of the 1st row (btw width of (3,1) is ok, that problem
appears just with vertically merged cells).
Maybe there's a property that indicate a merged range?

What's the correct method to get all merged cells at all?

Thank you in advance,
A. Dzizenko.
 
C

Cindy M.

Hi Andrey,

to put it succinctly, you just can't do much more than For each to access
each cell in turn. Word's object model wasn't designed to support working
with merged cells using automation.

If you (Google) search the word.vba.general and word.table newsgroups you'll
find a number of discussions that give partial workarounds. You can get a
certain amount of control if the cells in your table are merged either
horizontally or vertically, but not both.

The best approach, really, is to export to HTML format then read the HTML
file, as that gives row and column spans.
Explain me please how should I enumerate all cells in a MSWord's table
(using automation of course). There're merged cells in a table, something
like that:

┌──────┬────────â”
│ │ │
│ ├────────┤
│ │ │
├──────┴────────┤
│ │
└───────────────┘

If I try to get access to the cell (2,1), I have an exception.
If I try to get (1,1), it looks like it's not a part of a merged cell.
E.g. it has height of the 1st row (btw width of (3,1) is ok, that problem
appears just with vertically merged cells).
Maybe there's a property that indicate a merged range?

What's the correct method to get all merged cells at all?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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