Get Word Field Name?

G

George Lee

How can I get the name of a Word Field or Bookmark that was clicked or entered?

For example, I have many fields I want a date userform to appear on. When
the user selects a date, the field gets updated. Each field should use the
same function, and is independent of any other field. There should be no
reason each OnEnter macro should unique.

Word 2003, Windows XP.
 
J

Jay Freedman

George said:
How can I get the name of a Word Field or Bookmark that was clicked
or entered?

For example, I have many fields I want a date userform to appear on.
When
the user selects a date, the field gets updated. Each field should
use the same function, and is independent of any other field. There
should be no reason each OnEnter macro should unique.

Word 2003, Windows XP.

Selection.Bookmarks(1).Name will return the name of the field that was just
entered.

Caveat: This assumes there isn't another bookmark that includes the field.
If that's the case, you might have to iterate through the
Selection.Bookmarks collection looking for a name that matches your field
naming convention (which implies that you have such a convention and
followed it faithfully <g>).

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
J

Jean-Guy Marcil

George Lee said:
How can I get the name of a Word Field or Bookmark that was clicked or entered?

For example, I have many fields I want a date userform to appear on. When
the user selects a date, the field gets updated. Each field should use the
same function, and is independent of any other field. There should be no
reason each OnEnter macro should unique.

Like this:

Selection.Bookmarks(1).Range.FormFields(1).Name
 

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