Mike was telling us:
Mike nous racontait que :
>>> Hi,
>>
[quoted text clipped - 61 lines]
>
> Mike
Instead of renaming the formfields already in place, you should rename the
one you just inserted in the document before you fill them out with text.
The reason being that if you insert formfields that have the same name as
exiting formfields, Word will internally choke and if you try to run simple
code like:
myFormField.Name = "Test" & i
Word will return an error on those fields that had conflicting names.
There is a workaround (my code below) but that removes the formfield content
and resets it to its default value. This is fine with fresh formfields that
do not have content yet, but not with existing ones.
'_______________________________________
Sub RenameFormfields()
Dim lngSecNumber As Long
If Selection.Sections.Item(1).Index = 1 Then
MsgBox "You cannot use this procedure from the first section in the
document."
Exit Sub
End If
lngSecNumber = Selection.Sections.Item(1).Index
With ActiveDocument.Sections(lngSecNumber).Range
.FormFields(1).Select
With Dialogs(wdDialogFormFieldOptions)
.Name = "Name" & lngSecNumber
.Execute
End With
.FormFields(2).Select
With Dialogs(wdDialogFormFieldOptions)
.Name = "Place" & lngSecNumber
.Execute
End With
End With
'_______________________________________
But, if you use a "clean" system, you can use something like:
myFormField.Name = "Test" & i
For that to Work, create an Autotext with the formfields, the text and the
section break and name those formfields "Name" and "Place".
Insert them in the first section and run code like:
'_______________________________________
Dim lngSecNumber As Long
lngSecNumber = Selection.Sections.Item(1).Index
With ActiveDocument.Sections(lngSecNumber).Range
.FormFields(1).Name = "Name" & lngSecNumber
.FormFields(2).Name = "Place" & lngSecNumber
End With
'_______________________________________
Every time you insert a new section, run the code to rename the formfields.
This way you will never have conflicting names.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Mike - 15 Feb 2007 17:16 GMT
> Mike was telling us:
> Mike nous racontait que :
[quoted text clipped - 138 lines]
>
> - Tekst uit oorspronkelijk bericht weergeven -
Thanks, you helped me a great deal!
Mike