Word Form “Text Field†Change Question

G

George Lee

When using Word form “text field,†how is it possible to get an onchange
event? The Text Form Field Options dialog supports running a macro on
entering or exiting the field. I want to detect when the field has changed
and take additional actions.
 
J

Jay Freedman

George said:
When using Word form "text field," how is it possible to get an
onchange event? The Text Form Field Options dialog supports running a
macro on entering or exiting the field. I want to detect when the
field has changed and take additional actions.

Sorry, it is not possible. There is no such event.

The alternative is to create an on-entry macro that displays a userform. In
the userform, text entry controls do have change events, as well as
key-down, key-up, key-pressed, and mouse-click events. When the userform's
OK button is clicked, you can also do validation before dismissing the
userform. Finally, the macro can copy the contents of the userform's text
control to the form field in the document.

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

fumei via OfficeKB.com

No on change event, but you could have a global string variable that is set
by an On Exit macro, with the On Entry macro checking against that global
string variable.

On Exit

strMyValue = the formfield .Result

On Entry

If strMyValue = whatever Then
 
J

Jay Freedman

Hmm, interesting idea, but I think the sequence is backwards. For one thing,
there's no assurance that the user will ever re-enter the field after exiting
it.

The intention of an on_change handler is usually to react as soon as the value
has changed. That implies that the On Entry macro should store the current value
of the field result; the On Exit macro should do the comparison to see whether
the value changed while the focus was in the field and trigger the action if
needed.
 

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