Deleting blank rows / columns in a Word 2002 Table

R

Renegade

Does anyone know a quick method or have a macro written to delete blank rows
and/or columns contained in a Word 2002 Table. Please share, I would be most
grateful. Thank you in advance for any replies.
 
H

Helmut Weber

Hi Renegade,

like that:

Sub Test456()
Dim oTbl As Table
Dim oRow As Row
Dim oClm As Column
Dim oCll As Cell
Dim LngT As Long
Set oTbl = ActiveDocument.Tables(1)
For Each oRow In oTbl.Rows
If Len(oRow.Range) = (oRow.Cells.Count * 2) + 2 Then
oRow.Delete
End If
Next
For Each oClm In oTbl.Columns
LngT = 0
For Each oCll In oClm.Cells
' as there is no column range
If Len(oCll.Range) > 2 Then
Exit For ' for speed reasons only
End If
LngT = LngT + 2
Next
If LngT = oClm.Cells.Count * 2 Then
oClm.Delete
End If
Next
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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