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
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