Word FormField focus

Discussion in 'Word VBA' started by wdVBANovice, Jul 19, 2008.

  1. wdVBANovice

    wdVBANovice Guest

    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?
     
    wdVBANovice, Jul 19, 2008
    #1
    1. Advertising

  2. wdVBANovice

    Jay Freedman Guest

    On Fri, 18 Jul 2008 21:50:00 -0700, wdVBANovice
    <> wrote:

    > 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.

    --
    Regards,
    Jay Freedman
    Microsoft Word MVP FAQ: http://word.mvps.org
    Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
     
    Jay Freedman, Jul 19, 2008
    #2
    1. Advertising

  3. wdVBANovice

    wdVBANovice Guest

    great thank you


    "Jay Freedman" wrote:

    > On Fri, 18 Jul 2008 21:50:00 -0700, wdVBANovice
    > <> wrote:
    >
    > > 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.
    >
    > --
    > Regards,
    > Jay Freedman
    > Microsoft Word MVP FAQ: http://word.mvps.org
    > Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
    >
     
    wdVBANovice, Jul 19, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leo
    Replies:
    0
    Views:
    88
  2. Leo
    Replies:
    3
    Views:
    97
  3. Micheline

    Formfield to Formfield

    Micheline, Sep 21, 2004, in forum: Word Tables
    Replies:
    3
    Views:
    86
    Jay Freedman
    Sep 21, 2004
  4. Peter Lingo

    Which formfield has the focus

    Peter Lingo, Aug 26, 2004, in forum: Word VBA
    Replies:
    7
    Views:
    45
    Peter Hewett
    Aug 27, 2004
  5. Thomas M

    Jump from FormField to FormField

    Thomas M, Nov 14, 2005, in forum: Word VBA
    Replies:
    2
    Views:
    74
    Thomas M
    Nov 15, 2005
Loading...

Share This Page