Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Feb 2002
    Location
    PA
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help text in FORM FIELD (W2K)

    I've created a test - and placed form fields for their answers. If they tab from field to field, it works great. But if they click in a field, they type in the middle the the help text of "Type your answer here" and it comes back as "Type youTHEIR ANSWER TEXTr answer here". Is there a way I can get the help text highlighted when they click in the field?

  2. #2
    Lounger
    Join Date
    Jan 2001
    Location
    Harrisburg, Pennsylvania, USA
    Posts
    44
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Re: Help text in FORM FIELD (W2K)

    You could try adding a macro that occurs upon form field entry.
    Record a macro (I called mine HiLite ). Once you start recording, press the home key, then press Ctrl + Shift + Down arrow one time. Stop recording.
    Now double click on your form fields (while not locked) and in the lower left corner, click the Entry drop down list and select your macro name.
    This will do what you want it to do, but the students will need to be careful! If they go back to an answer to edit it later, they'll need to double click - or risk loosing their whole answer!!!
    Hope this helps -
    M Morrow

  3. #3
    New Lounger
    Join Date
    Feb 2002
    Location
    PA
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help text in FORM FIELD (W2K)

    I tried this and it seemed as if it ran the macro, but didn't KEEP the form field selected, because I was still able to click in the field and type in the middle of the help text. I'll try it again - maybe I didn't set it up correctly.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Help text in FORM FIELD (W2K)

    Word can't do that, because the macro only runs when entering or exiting the field, not when clicking inside it.

    You could modify your macro so that if the field contains only the default text, you clear it, but if it contains anything else, you leave it alone. The code for that would be something like:
    <pre>Sub EntryForName()
    'On enter macro for a field named "Name" (the Bookmark for the field)
    Dim frmfld As FormField
    Set frmfld = ActiveDocument.FormFields("Name")
    If frmfld.Result = "Type Your Name Here" Then 'Case sensitive!
    frmfld.Result = vbNullString
    End If
    Set frmfld = Nothing
    End Sub</pre>

    If someone knows of a way to identify the field the user clicked from inside the macro, then you might be able to simplify this down to one on entry macro for all fields. Hope this helps.

  5. #5
    New Lounger
    Join Date
    Feb 2002
    Location
    PA
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help text in FORM FIELD (W2K)

    Here's what I've put in -- and it works.
    Can someone tell me how to set the field name (bookmark) to a variable... like in this line of code (as seen below) bkmField = Bookmark() .

    Sub Highlight()
    ' Macro recorded 6/11/2002
    ' Selection.HomeKey Unit:=wdLine
    ' Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
    'On enter macro for a field named "Name" (the Bookmark for the field)
    Dim frmfld As FormField
    Dim bkmField As Bookmark
    bkmField = Bookmark()
    Set frmfld = ActiveDocument.FormFields(bkmField)
    If frmfld.Result = "Type your answer here" Then 'Case sensitive!
    frmfld.Result = vbNullString
    End If
    SendKeys "{Home}"
    Set frmfld = Nothing
    bkmField = ""
    End Sub

    Thanks!

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Help text in FORM FIELD (W2K)

    Peggie,

    It's very hard to imagine that code working, as you report - it doesn't even compile. In particular:

    Dim bkmField As Bookmark
    bkmField = Bookmark()

    just aren't digestible.
    You may want to do something like:

    Dim strbkmName As String

    but in the current macro there's no need for a string variable anyway; the following amended version seems to work (although Jefferson's version is much cleaner):

    Sub Highlight()
    ' Macro recorded 6/11/2002
    Dim frmfld As FormField
    Set frmfld = ActiveDocument.FormFields("Name")
    If frmfld.Result = "Type your answer here" Then
    frmfld.Result = vbNullString
    End If
    SendKeys "{Home}"
    Set frmfld = Nothing
    End Sub

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Help text in FORM FIELD (W2K)

    Hi Jefferson,

    I think you can get at the name of the field that's been clicked in, by getting the name of the bookmark:

    strFieldBmkName = Selection.Bookmarks(1).Name

    which should then permit a generic procedure to be written that can be run on entry for all fields.

    Gary

  8. #8
    New Lounger
    Join Date
    Feb 2002
    Location
    PA
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help text in FORM FIELD (W2K)

    Thanks!!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •