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

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

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

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. Robert S.
    Replies:
    7
    Views:
    98
    Cindy Meister -WordMVP-
    Aug 17, 2003
  2. Lynn
    Replies:
    1
    Views:
    95
    Peter Hewett
    Feb 24, 2004
  3. Guest
    Replies:
    5
    Views:
    100
    Guest
    Jul 13, 2004
  4. Peter Lingo

    Which formfield has the focus

    Peter Lingo, Aug 26, 2004, in forum: Word VBA
    Replies:
    7
    Views:
    167
    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:
    151
    Thomas M
    Nov 15, 2005
  6. Ro-zToy
    Replies:
    5
    Views:
    118
    Summer
    Nov 22, 2007
  7. jacobk

    Set formfield focus on Multipage

    jacobk, Oct 26, 2008, in forum: Word VBA
    Replies:
    3
    Views:
    92
    Gordon Bentley-Mix
    Oct 28, 2008
  8. jjfeenix
    Replies:
    2
    Views:
    98
    jjfeenix
    Aug 11, 2009
Loading...