• Finding things NOT a field (WXP)

    Author
    Topic
    #422635

    Howdy folks,

    I’m a proofreader/editor, and one of things I have to find is instances where references to Tables or Figures are NOT cross-referenced properly–in other words, find cases where the word “Table” (or “Figure”) is NOT a field.

    Anyone got some code to do this?

    Thanks,

    Beej

    Viewing 0 reply threads
    Author
    Replies
    • #964496

      Not the speediest, but it works:

      Sub FindTablesAndFiguresNotInFields()
      Dim doc As Document
      Dim para As Paragraph
      Dim wrd As Range
      Set doc = ActiveDocument
      For Each para In doc.Paragraphs
          With para.Range.Find
              .ClearFormatting
              .MatchCase = True
              .MatchWildcards = True
              .Text = "[TF][ableigur]{4,5}"
              If .Execute Then
                  For Each wrd In para.Range.Words
                      If Trim(wrd) = "Table" Or _
                         Trim(wrd) = "Figure" Then
                          If wrd.Fields.count = 0 Then
                              wrd.HighlightColorIndex = wdBrightGreen
                          End If
                      End If
                  Next wrd
              End If
          End With
      Next para
      End Sub
      
    Viewing 0 reply threads
    Reply To: Finding things NOT a field (WXP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: