> I have code that inserts autotext entries into a document. I need to change
> the name of the form fields that are in those autotext entries based on the
[quoted text clipped - 11 lines]
>
> Thanks in advance for any help!
Thanks and sorry about not elaborating, but here is the code I'm using:
Public Sub ChangeDictBMName(DictAcr As String)
Dim ff As FormField
Dim tempName As String
On Error GoTo ErrHndler
For Each ff In ActiveDocument.FormFields
If Mid$(ff.Name, 11, Str(Len(DictAcr))) = DictAcr And Right$(ff.Name, 1)
= "x" Then
tempName = Left$(ff.Name, Len(ff.Name) - 1) & Str$(glbThisSuppQty)
ff.Name = tempName
End If
Next ff
Exit Sub
ErrHndler:
ret = MsgBox(Err.Number & ": " & Err.Description, , "LC Standard Report:
ChangeDictBMName")
End Sub
Before I enter into this code, I've looked for the autotext entry to see if
it is already inserted into the document by searching for a bookmark, and
determined how many of that entry has already been inserted into the
document. That number is stored in glbThisSuppQty. I then insert the
autotext entry then go into the code above. The passed argument, DictAcr,
holds values such as "N", "PR", "PL", etc. One autotext entry has multiple
form fields named, for example, "DICTATION_N1_x", "DICTATION_N2_x",
"DICTATION_N3_x", etc. The "x" needs to be changed to the number of copies
of that autotext entry.
I hope this helps a little.
Thanks
> ActiveDocument.FormFields(1).Name = "Text3" changes the name of the first
> formfield in the document to Text3 for me.
[quoted text clipped - 17 lines]
> >
> > Thanks in advance for any help!
Doug Robbins - 06 Feb 2005 13:27 GMT
Are you sure that the duplicate formfields have a name in the first place?
If I insert a formfield Text1, then copy and paste it into another place in
the document, the pasted formfield does not have a name.
See the article "How to assign a Name to a FormField that doesn't already
have a Name, using VBA" at:
http://word.mvps.org/FAQs/MacrosVBA/AssignNameToFmFld.htm

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Thanks and sorry about not elaborating, but here is the code I'm using:
>
[quoted text clipped - 69 lines]
>> >
>> > Thanks in advance for any help!
skbrown14 - 06 Feb 2005 16:21 GMT
Thanks, that worked. I actually ran into some problems to begin with but
found out that I was trying to name the formfield with a space in it. Once I
found that and used Trim to take off spaces, the
Dialogs(wdDialogFormFieldOptions).Execute worked great.
Thanks alot!
> Are you sure that the duplicate formfields have a name in the first place?
> If I insert a formfield Text1, then copy and paste it into another place in
[quoted text clipped - 78 lines]
> >> >
> >> > Thanks in advance for any help!