View Single Post
 
Old 03-30-2015, 05:50 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,635
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub 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
     Wend
   End With
    Set oRng = ActiveDocument.Range
   Selection.Find.ClearFormatting
   With oRng.Find
     .Text = ChrW(9744)
     While .Execute
       Set oCC = ActiveDocument.ContentControls.Add(wdContentControlCheckBox, oRng)
       oCC.Checked = True
       oRng.Collapse wdCollapseEnd
     Wend
   End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote