![]() |
#1
|
|||
|
|||
![]()
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 |
#2
|
||||
|
||||
![]()
Try:
Code:
Sub AddChkBox() With ActiveDocument .FormFields.Add Range:=.Range.Characters.Last, Type:=wdFieldFormCheckBox .Characters.Last.Previous.Cut With .Content.Find .ClearFormatting .Text = "[_]{1,}" With .Replacement .ClearFormatting .Text = "^c" End With .Format = False .Forward = True .Wrap = wdFindContinue .MatchWildcards = True .Execute Replace:=wdReplaceAll End With End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
If I discern correctly, you inserted the checkbox, cut it to the clipboard, launched Find for "at least one" underscore, replaced these with the clipboard contents, and then replaced all. Looks like a great model for any such operation. Much appreciated.
Ulodesk |
#4
|
||||
|
||||
![]()
Precisely!
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Tags |
checkbox, form field |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
tinfanide | Word | 2 | 10-06-2012 11:04 PM |
![]() |
smohap | Word | 1 | 06-19-2011 09:24 PM |
![]() |
theresamille699 | Excel | 3 | 04-12-2011 08:08 PM |
Ticking Checkboxes | screid | Word | 1 | 06-08-2010 02:04 AM |
Manipulating checkboxes in XML | Ivo | Word | 0 | 12-06-2005 09:04 AM |