View Single Post
 
Old 03-14-2014, 07:02 AM
Ulodesk Ulodesk is offline Windows 7 64bit Office 2013
Word 2013 Expert Cert
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Replacing underscores with checkboxes

My purpose is simply to replace each series of underscores in a would-be form document (between 3 and 6, for instance; I tried with 4 here) with a legacy checkbox. I have recorded two macros but don't know how to insert the relevant part of the first (inserting a checkbox) into the second.

In the code below, the replacement line with the $ is undoubtedly extraneous; I was trying to see the macro language in case it would help me in substituting the checkbox for the $.

Code:
Sub Box()
'
' Box Macro
'
'
    Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormCheckBox
    Selection.TypeText Text:=" "
End Sub

Sub BoxA()
'
' BoxA Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "____"
        .Replacement.Text = "$"
        .Forward = True
        .Wrap = wdFindContinue
        
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Thanks in advance.
Reply With Quote