Hi,
I don't have much understanding of MS Word macros, but I am trying to create a macro that would replace all my form checkboxes with content control checkboxes. The newly replaced checkboxes should reflect the old state of the legacy checkboxes. Note that in the document both types of checkboxes can be found and only the legacy ones must be replaced (I have attached an example).
Replace checkboxes.docx
Replace checkboxes.docx
I've found the following code and I tried to adjust it to work for my case, but I keep getting errors:
Any tips or help is highly appreciated!Replace checkboxes.docxSub Checkbox()Dim oRng As Word.Range Dim oCC As ContentControl 'ChrW(9744) is unchecked box; 9746 is checked box Set oRng = ActiveDocument.Range Selection.Find.ClearFormatting With oRng.Find .Text = ChrW(9744) .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False While .Execute Set oCC = ActiveDocument.ContentControls.Add(wdContentControlCheckBox, oRng) oCC.Checked = False oRng.Collapse wdCollapseEnd oRng.Move wdCharacter, 2 Wend End With Set oRng = ActiveDocument.Range Selection.Find.ClearFormatting With oRng.Find .Text = ChrW(9746) While .Execute Set oCC = ActiveDocument.ContentControls.Add(wdContentControlCheckBox, oRng) oCC.Checked = True oRng.Collapse wdCollapseEnd oRng.Move wdCharacter, 2 Wend End With lbl_Exit: Exit Sub End Sub