Design Macro or Code to Delete Table Rows When Null/Blank/Empty Upon Doc Close/Save
This is the code I am trying. When I saved the file (.docm) it didn't work. What am I doing wrong? Please! Thanks!
Private Sub oApp_DocumentBeforeSave(ByVal Doc As Document, _
SaveAsUI As Boolean, Cancel As Boolean)
Sub DelRows()
Application.ScreenUpdating = False
Dim r As Long
With ActiveDocument.Tables(1)
For r = .Rows.Count To 1 Step -1
With .Rows(r)
If .Range.Fields.Count > 0 Then .Delete
End With
Next
End With
Application.ScreenUpdating = True
End Sub
Last edited by aaghd72; 02-15-2019 at 10:47 AM.
Reason: Added Document
|