View Single Post
  #2   Report Post  
KWC via OfficeKB.com
 
Posts: n/a
Default

Here is what I ended up doing and it works. Got help from the WOPR board.

Function RowIsBlank(r As Word.Row) As Boolean
If Len(Replace(r.Range.Text, Chr(13) & Chr(7), vbNullString)) = 0 Then ' Chr
13 and 7 are paragraph marker and end cell marker
RowIsBlank = True 'row contain no text
Else
RowIsBlank = False 'row contains some text
End If
End Function

Sub Delete_Blank_Rows()
Dim odoc1 As Document
Dim oTable As Table
Dim rw As Word.Row
Dim lngrow As Integer
Dim row_cnt As Integer

MacroEntry
Selection.HomeKey Unit:=wdStory
If ActiveDocument.Tables.Count = 1 Then
Set odoc1 = ActiveDocument
For Each oTable In odoc1.Tables
On Error Resume Next
For lngrow = oTable.Rows.Count To 1 Step -1
On Error Resume Next
If RowIsBlank(oTable.Rows(lngrow)) Then
oTable.Rows(lngrow).Delete
If Err.Number = 0 Then
row_cnt = row_cnt + 1
End If
End If
Next lngrow
Next oTable
End If
MacroExit
Selection.HomeKey Unit:=wdStory
MsgBox "Finished - " & row_cnt & " blank rows were deleted"
End Sub

Sub MacroEntry()
Sbar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
Application.ScreenUpdating = False
End Sub

Sub MacroExit()
Application.StatusBar = False
Application.DisplayStatusBar = Sbar
Application.ScreenUpdating = True
End Sub

--
Message posted via http://www.officekb.com