2
votes

I have a very long word file, containing several tables. Each table contains a list of items that may or may not be applicable to the user.

I am trying to find a way of hiding/masking rows that have not been filled by the user.

To do so, I was thinking of writing a sub that go through the entire document lookinf for content controls, then checks if the contentcontrol.text="NULL" and then deletes the table row (or hides it by setting the row height to 0).

Any ideas?

Below my partial attempt

Sub HideRows()
Dim d As Document
Set d = ActiveDocument
Dim cc As ContentControl

For Each cc In d.ContentControls         
    If cc.Range.Text = "NULL" Then

        'Delete the table row where this content control is located


    End If
Next
End Sub
1

1 Answers

0
votes

Assuming that:

  • each ContentControl covers the whole single row
  • you do not use nested tables in document

you can place this code inside your if statement:

CC.Range.Tables(1).Rows(CC.Range.Information(wdEndOfRangeRowNumber)).Delete