Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting Focus on a Word Form (2003)

    Upon opening the attached doc file, is it possible to set the focus on the cmbUnit combo box rather than the Controllo1 check box?
    Attached Files Attached Files

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Setting Focus on a Word Form (2003)

    Put the following code in the ThisDocument module (not in a standard module!):

    Private Sub Document_Open()
    Me.FormFields("cmbUnit").Select
    End Sub

  4. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Focus on a Word Form (2003)

    Thank you Hans, is there any way to avoid launching the TransferShipper Sub in the Modulo1 module when the document opens and only run it when you put a check in the Controllo1 check box?

  5. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Setting Focus on a Word Form (2003)

    Do you have a particular reason for having TransferShipper as On Enter macro for the check box instead of as On Exit macro?

  6. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Focus on a Word Form (2003)

    Thank you Hans, I've moved TransferShipper to the On Exit macro but even now when I check the Controllo1 check box, TranferShipper doesn't run.
    Attached Files Attached Files

  7. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Setting Focus on a Word Form (2003)

    The code runs when you exit the check box, not when you click it. That's the way formfields work in Word.

  8. #7
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Focus on a Word Form (2003)

    Thank you Hans, I suppose the only way out is to add a custom control to a toolbar in order to execute the sub. In TransferShipper I'm able to clear the content of the form text boxes using
    TextInput.Clear
    but what's the code to clear the content of the cmbUnit combo box?

  9. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Setting Focus on a Word Form (2003)

    A form dropdown (combo box) always has a value, you can't clear it. You can simulate it by adding an item to the list that consists of one space, and setting the result of the dropdown to that item:
    <code>
    ActiveDocument.FormFields("cmbUnit").Result = " "</code>

  10. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Setting Focus on a Word Form (2003)

    You could also use the check box from the Control Toolbox. This has an On Click event, similar to a check box in Access.

  11. #10
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Focus on a Word Form (2003)

    Thank you Hans!!! <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> I've set the Type: box in the text form field options box to "Current date" but I see that when the day changes the date shown in the txtGiorno text box stays the same.
    Attached Files Attached Files

  12. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Setting Focus on a Word Form (2003)

    Have you tried print previewing the document? Some fields don't update until you print or print preview.
    You can also use a Date field instead of a form field.

  13. #12
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Focus on a Word Form (2003)

    The user needs to see the current date right off the bat as soon as he/she opens the file without the need to print previewing it. How do you insert a Date field?
    Anyway, this one works as well:
    <pre>Private Sub Document_Open()
    Dim oStory As Object
    Me.FormFields("cmbUnit").Select
    For Each oStory In ActiveDocument.StoryRanges
    oStory.Fields.Update 'update fields in all stories
    Next oStory
    End Sub</pre>


  14. #13
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Focus on a Word Form (2003)

    There must be a way to update only the txtGiorno field but I dont know how.

  15. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Setting Focus on a Word Form (2003)

    Select Insert | Date and Time...
    Select the format you like.
    Tick the check box "Update automatically".
    Click OK.

    - or -

    Select Insert | Field...
    Select Date in the list of field names.
    Select the format you like.
    Click OK.

  16. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Setting Focus on a Word Form (2003)

    ActiveDocument.Bookmarks("txtGiorno").Range.Fields (1).Update

Page 1 of 2 12 LastLast

Posting Permissions

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