S
Steve Lang
Hi all,
I have a document with a number of form fields that are inserted into the
document with an autotext trigger.
Each time the autotext is inserted, the same formfield names are used again
and again with the expectation that the newest would take the name - similar
action to inserting a new bookmark with the same name as an existing
bookmark.
After inserting the new text including formfields, when I check the
properties of the newer formfield, it does indeed have the updated bookmark
name. Unfortunately, code to insert the text into the formfield, still uses
the old formfield:
Activedocument.Formfields("Subject").Result = "blah"
populates the OLD formfield and the following two code lines don't result in
selecting the same formfield:
Activedocument.Bookmarks("Subject").Range.Select
Activedocument.Formfields("Subject").Range.Select
Here's where it gets weird: If I manually select the properties of the old
formfield, the bookmark name is blank - as it should be - and subsequently
running the above code lines work as expected! There is something that is
changing when I manually select the properties of the formfield. Is there a
way to make that happen via code?
I also found out that:
Activedocument.Bookmarks("Subject").Range.FormFields(1).Result
= "blah"
throws an error. However, the following combined lines of code does work:
Activedocument.Bookmarks("subject").Range.Select
Selection.FormFields(1).Result = "blah"
I'd rather not have to select each range before populating it. Ideally the
topmost line of code would operate as it expected. Is there a different
approach that I could take short of selecting each bookmark and using the
selection object?
TIA and have a great day!
Steve Lang
I have a document with a number of form fields that are inserted into the
document with an autotext trigger.
Each time the autotext is inserted, the same formfield names are used again
and again with the expectation that the newest would take the name - similar
action to inserting a new bookmark with the same name as an existing
bookmark.
After inserting the new text including formfields, when I check the
properties of the newer formfield, it does indeed have the updated bookmark
name. Unfortunately, code to insert the text into the formfield, still uses
the old formfield:
Activedocument.Formfields("Subject").Result = "blah"
populates the OLD formfield and the following two code lines don't result in
selecting the same formfield:
Activedocument.Bookmarks("Subject").Range.Select
Activedocument.Formfields("Subject").Range.Select
Here's where it gets weird: If I manually select the properties of the old
formfield, the bookmark name is blank - as it should be - and subsequently
running the above code lines work as expected! There is something that is
changing when I manually select the properties of the formfield. Is there a
way to make that happen via code?
I also found out that:
Activedocument.Bookmarks("Subject").Range.FormFields(1).Result
= "blah"
throws an error. However, the following combined lines of code does work:
Activedocument.Bookmarks("subject").Range.Select
Selection.FormFields(1).Result = "blah"
I'd rather not have to select each range before populating it. Ideally the
topmost line of code would operate as it expected. Is there a different
approach that I could take short of selecting each bookmark and using the
selection object?
TIA and have a great day!
Steve Lang