Click here to Skip to main content
12,950,090 members (39,585 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
hi all
i have a table in my word doc. i need to get the rowspan and colspan values of cells in this table from the vba code. becouse i want to convert it in a html doc.

if table is simple i.e. there is no rowspan and colspan then i have no problem. i use this code :
Function replace_tables()
' convert simple tables (no merged cells!)
Dim oRow As Row
Dim oCell As Cell
Dim sCellText As String
Dim tTable As Table
Dim noRows, noCells As Long
 
'StatusBar = "Convert tables..."
   
For Each tTable In ActiveDocument.Tables
    For Each oRow In tTable.Rows
        For Each oCell In oRow.Cells
            sCellText = oCell.Range
            sCellText = Left$(sCellText, Len(sCellText) - 2)
            If Len(sCellText) = 0 Then sCellText = " "
            sCellText = "<td>" & sCellText & "</td>"
            oCell.Range = sCellText
        Next oCell
        sCellText = oRow.Cells(1).Range
        sCellText = Left$(sCellText, Len(sCellText) - 2)
        sCellText = "<tr>" & vbCr & sCellText
        oRow.Cells(1).Range = sCellText
        sCellText = oRow.Cells(oRow.Cells.Count).Range
        sCellText = Left$(sCellText, Len(sCellText) - 2)
        sCellText = sCellText & vbCr & "</tr>"
        oRow.Cells(oRow.Cells.Count).Range = sCellText
    Next oRow
    sCellText = tTable.Rows(1).Cells(1).Range
    sCellText = Left$(sCellText, Len(sCellText) - 2)
    sCellText = "<table>" & vbCr & sCellText
    tTable.Rows(1).Cells(1).Range = sCellText
    noRows = tTable.Rows.Count
    noCells = tTable.Rows(noRows).Cells.Count
    sCellText = tTable.Rows(noRows).Cells(noCells).Range
    sCellText = Left$(sCellText, Len(sCellText) - 2)
    sCellText = sCellText & vbCr & "</table>"
    tTable.Rows(noRows).Cells(noCells).Range = sCellText
    tTable.ConvertToText Separator:=wdSeparateByParagraphs
Next tTable
 
End Function


but i want to write a code for table which has merged cells in it.
can somebody help me regarding this.. i am searching over the internet for my problem from last night.so please avoid pasting any link in solution, because i had already seen most of them.
Posted 13-Jan-13 22:00pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,749
CHill60 3,380
Maciej Los 2,953
Jochen Arndt 1,935
ppolymorphe 1,820


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 10 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100