![]() |
|
#2
|
||||
|
||||
|
Try:
Code:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim Tbl As Table, cel As Cell, r As Long, x As Long
Dim bDel As Boolean, CCtrl As ContentControl
With ActiveDocument
For Each Tbl In .Tables
For r = Tbl.Rows.Count To 1 Step -1
With Tbl.Rows(r)
If Len(.Range.Text) = .Cells.Count * 2 + 2 Then
.Delete
Else
bDel = True
For Each cel In .Cells
If Len(cel.Range.Text) > 2 Then
If .Range.ContentControls.Count = 0 Then
bDel = False: Exit For
Else
For Each CCtrl In .Range.ContentControls
If CCtrl.ShowingPlaceholderText = False Then
bDel = False: Exit For
End If
x = x + Len(CCtrl.Range.Text)
Next
If x + 2 <= Len(cel.Range.Text) Then
bDel = False: Exit For
End If
End If
End If
Next cel
If bDel = True Then Tbl.Rows(r).Delete
End If
End With
Next r
Next Tbl
End With
Set cel = Nothing: Set Tbl = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Delete or merge Content controls with the same name
|
sylvio | Word VBA | 9 | 08-30-2017 01:46 AM |
Duplicating one or more table rows or an entire table with content controls
|
kevinbradley57 | Word VBA | 10 | 08-17-2017 02:13 PM |
| Macro to save docx to doc that checks compatibility and converts content controls to static content. | staicumihai | Word VBA | 4 | 10-12-2016 08:23 PM |
Delete All empty Rows - Print - Undo all Rows deleted
|
Bathroth | Word VBA | 1 | 10-01-2014 01:40 PM |
| Content Controls - Add Table Rows | dgiromini | Word VBA | 1 | 04-11-2014 03:04 PM |