How to make all table borders invisible in MS Word after copying from HTML

I am in a situation where I need to make a HTML report into a word report with nothing more that Ctrl+C or opening it with Word. I end up with a lot of nested tables.

Problem lies in the fact that CSS formats the table in HTML while in Word document they are left with horrible looking borders, that need to be invisible.

It would take extensive amounts of time to make each tables borders invisible.

Is there a way to make all borders of every table in document invisible?


Solution 1:

Create a macro in Word using the following code:

Sub SelectAllTables()
    Dim tbl As Table
    Application.ScreenUpdating = False
    For Each tbl In ActiveDocument.Tables
        tbl.Range.Editors.Add wdEditorEveryone
    Next
    ActiveDocument.SelectAllEditableRanges (wdEditorEveryone)
    ActiveDocument.DeleteAllEditableRanges (wdEditorEveryone)
    Application.ScreenUpdating = True
End Sub

Run the macro to select all tables, then you can modify their borders in one go:

1


Edit: Ok, this should be able to recursively handle nested tables as well to any level:

Sub SelectAllTables()
    Dim tbl As Table
    For Each tbl In ActiveDocument.Tables
        DelTableBorder tbl
    Next
End Sub

Function DelTableBorder(tbl As Table)
    Dim itbl As Table
    tbl.Borders(wdBorderLeft).Visible = False
    tbl.Borders(wdBorderRight).Visible = False
    tbl.Borders(wdBorderTop).Visible = False
    tbl.Borders(wdBorderBottom).Visible = False
    tbl.Borders(wdBorderVertical).Visible = False
    tbl.Borders(wdBorderHorizontal).Visible = False
    tbl.Borders(wdBorderDiagonalUp).Visible = False
    tbl.Borders(wdBorderDiagonalDown).Visible = False
    For Each itbl In tbl.Tables
        DelTableBorder itbl
    Next
End Function