Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-12-2017, 08:20 PM
macropod's Avatar
macropod macropod is offline Delete rows with content controls Windows 7 64bit Delete rows with content controls Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,520
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:
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]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete rows with content controls Delete or merge Content controls with the same name sylvio Word VBA 9 08-30-2017 01:46 AM
Delete rows with content controls 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 rows with content controls 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:51 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft