converting tables with merged rows/columns to text

D

Dig-it

Hi,
I'm trying to write a macro to convert Word tables to a Wiki syntax in
plain text, by adding delimiting tags to the cells.
See http://twiki.org/cgi-bin/view/Plugins/MsWordToTWikiMLAddOn

This is what such a wiki table might look like:
| *L* | *C* | *R* |
| A2 | 2 | 2 |
| A3 | 3 | 3 |
| multi span ||| <-------- notice a row merge by empty ||
| A4-6 | four | four |
|^| five | five |
|^| six | six |

|
3 row column merge indicated by ^


The following code works OK with 'normal' tables, but fails on tables
where cells are merged.

Somehow I need to:
- find out which cells are merged
- add the right number of additional tags to row merges
- insert carets (^) to all but the first of a column merge

If anybody could share some ideas that would be greatly appreciated!
Cheers,
Jos

------ CURRENT CODE
Private Sub ConvertTables()
Dim thisTable As Table
Dim thisRow As Row
Dim thisCell As Cell
For Each thisTable In ActiveDocument.Tables
For Each thisRow In thisTable.Rows
For Each thisCell In thisRow.Cells
thisCell.Range.InsertBefore "|"
thisCell.Range.Find.Execute FindText:="^p",
ReplaceWith:=" ", Format:=True, Replace:=wdReplaceAll,
MatchControl:=True
Next thisCell
thisRow.Range.InsertAfter "|"
Next thisRow
thisTable.ConvertToText Separator:=" "
Next thisTable
End Sub
 
D

Dig-IT

Just some pointers on how to detect cell merges in tables would already
be very welcome!
Thanks in advance,
Jos
 

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