Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

converting tables with merged rows/columns to text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dig-it - 07 Aug 2005 00:07 GMT
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
Dig-IT - 10 Aug 2005 14:38 GMT
Just some pointers on how to detect cell merges in tables would already
be very welcome!
Thanks in advance,
Jos

> Hi,
> I'm trying to write a macro to convert Word tables to a Wiki syntax in
[quoted text clipped - 42 lines]
>     Next thisTable
> End Sub
Doug Robbins - 10 Aug 2005 19:33 GMT
See

http://groups-beta.google.com/group/microsoft.public.word.tables/browse_thread/t
hread/998117da74e26cde/75a809237f5055d0?q=merged+cells&rnum=4#75a809237f5055d0


Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Just some pointers on how to detect cell merges in tables would already be
> very welcome!
[quoted text clipped - 47 lines]
>>     Next thisTable
>> End Sub
Dig-IT - 11 Aug 2005 11:59 GMT
> See
>
> http://groups-beta.google.com/group/microsoft.public.word.tables/browse_thread/t
hread/998117da74e26cde/75a809237f5055d0?q=merged+cells&rnum=4#75a809237f5055d0

Much appreciated, it didn't occur to me to search for COLSPAN or ROWSPAN...

Thanks Doug, I'll investigate,
Jos
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.