I have what could be a complicated issue and hope you can assist.
I want to loop a paragraph based on user input and change fields at the same time. You are probably asking, "say what??"
Here is my paragraph
The Defendant, {MERGEFIELD Defendant_1} cannot afford to pay for an attorney, however legal advice may be available by contacting.............
Here are my field names in the database
Defendant_1
Defendant_2
Defendant_3
Defendant_4
Defendant_5 and so on.
If user selects 3 from a dropdown list, how do I get the numbers at the end of each mergefield to change on each loop? I believe SEQ does the trick but how (in VBA)? Here is a macro I recorded with attempts to use in vba but it does not work. Forgive me but I am still an ametuer who tries.
Here is what I used in VBA
If Cbodef.ListIndex = 3 Then 'Cbodef is the name used in vba form field
Selection.GoTo What:=wdGoToBookmark, Name:="Defendants"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
Cbodef = 0
Do While cbodef < 4
Selection.TypeText Text:="The Defendant "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"MERGEFIELD Defendant_ ", PreserveFormatting:=True
Selection.MoveLeft Unit:=wdCharacter, Count:=18
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"SEQ \* Arabic", PreserveFormatting:=True
Selection.TypeText Text:=" cannot afford to pay for an attorney, however "
Selection.TypeText Text:="legal advice may be available by contacting T "
Selection.TypeText Text:="he Clerk's office."
Cbodef = Cbodef + 1
Loop
Thanks in advance for your help.
I am using Word 2007