FormFields

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
 
W

Word Heretic

G'day "Steve Lang" <[email protected]>,

Word has hard-coded smarts to sense whether the bookmark attached to a
formfield is already in use. FOILED AGAIN!

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Steve Lang reckoned:
 
S

Steve Lang

Hi Steve,

Thought as much. Although it releases the bookmark name to the newer
formfield if you manually select properties of the old formfield.

Oh well. I had to write a function to do what I wanted.

Thanks for responding.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top