View Single Post
 
Old 04-26-2013, 06:34 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try the following version of the macro. With this one, if any formfield on a given row between the 4th & last rows is not empty, that row will not be deleted.

Code:
Sub DeleteEmptyRows()
'Delete empty rows in the table
Application.ScreenUpdating = False
Dim StrPwd As String, i As Long, j As Long, bDel As Boolean
StrPwd = ""
With ActiveDocument
  If .ProtectionType = wdAllowOnlyFormFields Then .Unprotect Password:=StrPwd
  With .Tables(2)
    For i = .Rows.Count - 1 To 4 Step -1
      bDel = False
      With .Rows(i)
        If .Range.FormFields.Count > 0 Then bDel = True
        For j = 1 To .Range.FormFields.Count
          If Trim(.Range.FormFields(j).Result) <> "" Then
            bDel = False
            Exit For
          End If
        Next
        If bDel = True Then .Delete
      End With
    Next
  End With
  .Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=StrPwd
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote