THanks for the reply...
Actually, there could be up to 40 items to check, I was just using the first
two to set example. The users wants to pick and choose which ones to
insert.
Thanks,
Michael
LanWanMan was telling us:
LanWanMan nous racontait que :
> THanks for the reply...
>
> Actually, there could be up to 40 items to check, I was just using
> the first two to set example. The users wants to pick and choose
> which ones to insert.
With that many checkboxes, if the text to be inserted comes directly from
textboxes and does not need to be formatted, I would use one bookmark and
build a string to insert all the items in one go.
If this is not possible (there may be text between the bookmarks in the
document), then I would cycle each checkbox (you can use code like Russ')
and insert the text as needed.
To manage the bookmarks, I would name them all with a similar name
(Bookmark1, Bookmark2, Bookmark3, etc.) and just select the next available
bookmark using a the number in the name and a counter when cycling through
the checkboxes. Also, since there seems to be one checkbox for each textbox,
I would use a naming scheme such as:
CheckBox1 - textCheckBox1
CheckBox2 - textCheckBox2
CheckBox3 - textCheckBox3
etc.
Or any other scheme where the textbox name is the same as the checkbox,
except for a prefix or a suffix.
Using the code Russ suggested, you could get something like (there are other
ways, but let's stick to one way for now):
Dim myCounter As Long
Dim myControl As Control
myCounter = 0
For Each myControl In Me.Controls
If myControl.Name Like "CheckBox*" Then
myCounter = myCounter + 1
With ActiveDocument
.Bookmarks("Exclusion" & myCounter).Range _
.InsertBefore Me.Controls("text" & myControl.Name).Text
End With
End If
Next Control
(Untested... you may need to fiddle with it.)
Then, you could even add code for dealing with the unused bookmarks (you
would know how many are left because of myCounter).

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org