Results 1 to 3 of 3

Thread: Find and Replace for wdFieldFormCheckBox with text beside it

  1. #1
    VBAX Newbie
    Jun 2020

    Find and Replace for wdFieldFormCheckBox with text beside it


    Beginner here! I'm trying to use a macro in Word to find a Legacy checkbox (wdFieldFormCheckBox) with particular text beside it, in order to delete both the checkbox and the text. I was using the following to find text and replace it with nothing, but I don't know how to include the checkbox in the "Find" function. Thanks for your help in advance!

    Sub Test()
    With Selection.Find
    .Text = "Protocol"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = True
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
    End With

  2. #2
    Assuming the check box and text are alone in a paragraph then with the form unprotected:

    Sub Macro1()
    Dim oFF As FormField
    Dim orng As Range
        For Each oFF In ActiveDocument.FormFields
            If oFF.Type = wdFieldFormCheckBox Then
                Set orng = oFF.Range.Paragraphs(1).Range
                If InStr(1, orng.Text, "Protocol") > 0 Then
                    orng.Text = ""
                End If
            End If
        Next oFF
        Set oFF = Nothing
        Set orng = Nothing
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes

  3. #3
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Jul 2008
    Cross-posted at:
    Please read VBA Express' policy on Cross-Posting in Rule 3:
    Paul Edstein
    [Fmr MS MVP - Word]

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts