View Single Post
 
Old 06-02-2014, 09:01 AM
jpb103's Avatar
jpb103 jpb103 is offline Windows 7 64bit Office 2007
Advanced Beginner
 
Join Date: May 2014
Location: Thunder Bay, Ontario
Posts: 58
jpb103 is on a distinguished road
Default

Just pop a command button on your document and give this code a try:
Code:
'///////////////////////////////////////////////////////////
'//////////////////CommandButton1_Click/////////////////////
'/////This function deletes all empty rows from a table/////
'///////////////////////////////////////////////////////////
Private Sub CommandButton1_Click()
For Each Row In ActiveDocument.Tables(1).Rows
    'MsgBox Row.Cells(1).Range.Text
    If (Row.Cells(1).Range.Text = Chr(13) & Chr(7)) Then Row.Delete
Next Row
'/////////////////////////END///////////////////////////////
End Sub
Keep in mind that this code only checks the first (i.e. leftmost) cell in each row to see if it is empty.
*EDIT* Woops, you can remove the MsgBox line (it's commented out anyways). I was using it for testing.
Reply With Quote