View Single Post
 
Old 03-31-2015, 04:51 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,437
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Try this:

Code:
Option Explicit
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
       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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote