Word FormField focus

W

wdVBANovice

Hi: I've created a Word (2002) document template with text formfields, and
have macros set to run on exit of various formfields.

Is it possible to set the focus (actually move the cursor) of the
ActiveDocument back to the formfield that the user just exited within the
macro that was called on exit?

All I can find are SetFocus methods for active x controls (not formfields),
and the "Select" method of the Formfields collection doesn't seem to do
anything?
 
J

Jay Freedman

Hi: I've created a Word (2002) document template with text formfields, and
have macros set to run on exit of various formfields.

Is it possible to set the focus (actually move the cursor) of the
ActiveDocument back to the formfield that the user just exited within the
macro that was called on exit?

All I can find are SetFocus methods for active x controls (not formfields),
and the "Select" method of the Formfields collection doesn't seem to do
anything?

This statement "should" work to reselect the field named Text2 from the exit
macro of the same field:

ActiveDocument.Bookmarks("Text2").Range.Fields(1).Result.Select

As explained in http://www.word.mvps.org/FAQs/TblsFldsFms/ValidateFFields.htm,
though, there is a timing bug that needs to be worked around.

Also as mentioned there, it's a better idea to create a UserForm for data entry,
and transfer the final results to the document. That makes validation much
easier and has other advantages, too.
 
W

wdVBANovice

great thank you


Jay Freedman said:
This statement "should" work to reselect the field named Text2 from the exit
macro of the same field:

ActiveDocument.Bookmarks("Text2").Range.Fields(1).Result.Select

As explained in http://www.word.mvps.org/FAQs/TblsFldsFms/ValidateFFields.htm,
though, there is a timing bug that needs to be worked around.

Also as mentioned there, it's a better idea to create a UserForm for data entry,
and transfer the final results to the document. That makes validation much
easier and has other advantages, too.

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

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