K
KWC via OfficeKB.com
I need a macro that will look at all tables in a document, then delete any
rows in those tables where the entire row is blank.
This is just a start, and does not work. Would someone provide some guidence?
thanks in advance.
Option Explicit
Sub delete_blank_rows()
Dim odoc1 As Document
Dim lngRow As Long
Dim oTable As Table
Dim orow As Row
Selection.HomeKey Unit:=wdStory
If ActiveDocument.Tables.Count >= 1 Then
Set odoc1 = ActiveDocument
For Each oTable In odoc1.Tables
For lngRow = oTable.Rows.Count To 1 Step -1
If Selection.Text = "" Then
oTable.Rows(lngRow).Delete
End If
Next lngRow
Next oTable
End If
End Sub
rows in those tables where the entire row is blank.
This is just a start, and does not work. Would someone provide some guidence?
thanks in advance.
Option Explicit
Sub delete_blank_rows()
Dim odoc1 As Document
Dim lngRow As Long
Dim oTable As Table
Dim orow As Row
Selection.HomeKey Unit:=wdStory
If ActiveDocument.Tables.Count >= 1 Then
Set odoc1 = ActiveDocument
For Each oTable In odoc1.Tables
For lngRow = oTable.Rows.Count To 1 Step -1
If Selection.Text = "" Then
oTable.Rows(lngRow).Delete
End If
Next lngRow
Next oTable
End If
End Sub