Results 1 to 15 of 15
  1. #1
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    In a paragraph there are a few FormFields (FF) to be filled out by an end-user. One of the FFs is a datefield, formatted as "dd-MM-yyyy". Sometimes there's no room on a line to hold the complete date and FF is abbriviated. The users don't like that. Is there a (preferably easy) way to make sure this date FF is not abbreviated and kept together on one (the next) line?

  2. #2
    Platinum Lounger
    Join Date
    Jan 2001
    Posts
    3,788
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Keep FormField contents on 1 line (WinXP NL /

    Hi Jan

    You can put the date field inside an EQ field as shown in <post#=409788>post 409788</post#>

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

    Re: Keep FormField contents on 1 line (WinXP NL /

    Nice idea (I thought of it too <img src=/S/grin.gif border=0 alt=grin width=15 height=15>), but the user won't be able to enter anything in the form field if it is inside an EQ field <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

  4. #4
    Platinum Lounger
    Join Date
    Jan 2001
    Posts
    3,788
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Keep FormField contents on 1 line (WinXP NL /

    Good point, I have used the method with date fields before but never with form fields. Should have tested it first. <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>

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

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    Unfortunately, I can't think of a way to do this. The .TextInput.Format property of a form field is read-only, so you can't replace the hyphens in the date format with non-breaking hyphens.
    Instead of using form fields, you could create a UserForm (in VBA) to let the users enter the date (and other information). You can then place the date in the document with non-breaking hyphens.

  6. #6
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    Thanks Hans. I was afraid of that. <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

    But I came up with the idea of an ExitMacro using Selection.Information(wdVerticalPositionRelativeTo Page). If this is different for the first and last position in the FFs contents, then it's split over 2 lines. And that could be solved by putting a soft return just in front of the FF. I have to work it out in detail, but I there are possibilities, I think.

  7. #7
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    I have it working. And a lot easier than I thought up front. There's a FormField named Date_exp (expiration) in a paragraph of the doc that needs to be on 1 line. Chr(11) is a soft return (Shift+Enter). ProtectionOff and ProtectionOn are custom Subs that do what their names suggest...

    <pre>Public Sub ExitDate_exp()
    Dim dblStart As Double
    Dim dblEnd As Double
    Dim dblLength As Double

    dblLength = Len(ActiveDocument.FormFields("Date_exp").Result)
    With Selection
    .GoTo What:=wdGoToBookmark, Name:="Date_exp"
    dblStart = .Information(wdVerticalPositionRelativeToPage)
    .MoveRight Count:=dblLength
    dblEnd = .Information(wdVerticalPositionRelativeToPage)
    If dblStart <> dblEnd Then
    .GoTo What:=wdGoToBookmark, Name:="Date_exp"
    .Collapse Direction:=wdCollapseStart
    .MoveLeft
    ProtectionOff
    .InsertBefore Chr(11)
    ProtectionOn
    End If
    End With
    End Sub </pre>


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

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    Thanks for sharing. What happens if the user edits the document later on in such a way that there is enough room for Date_exp on the line above?

  9. #9
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    Good question! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Thanks for pointing that out. For now I think I'll put the Chr(11) inside the FF (by omitting the last .MoveLeft). Then the users can manually correct it if necessary. That buys me some time to fix this properly, because they want this asap.

  10. #10
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    I got it right this time...
    I removed the last .MoveLeft so that the Chr(11) is inserted as the first character into the FormField.
    Then added to the top of the Sub a test to see if the first character of the content of the FormFiled is a Chr(11) and if so, remove it and replace the old content with the new one. Anything else I missed Hans? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    <pre>Public Sub ExitDate_exp()
    Dim dblStart As Double
    Dim dblEnd As Double
    Dim dblLength As Double
    Dim strTemp As String

    strTemp = ActiveDocument.FormFields("Date_exp").Result
    If Left(strTemp, 1) = Chr(11) Then
    strTemp = Mid(strTemp, 2)
    ActiveDocument.FormFields("Date_exp").Result = strTemp
    End If
    dblLength = Len(ActiveDocument.FormFields("Date_exp").Result)
    With Selection
    .GoTo What:=wdGoToBookmark, Name:="Date_exp"
    dblStart = .Information(wdVerticalPositionRelativeToPage)
    .MoveRight Count:=dblLength
    dblEnd = .Information(wdVerticalPositionRelativeToPage)
    If dblStart <> dblEnd Then
    .GoTo What:=wdGoToBookmark, Name:="Date_exp"
    .Collapse Direction:=wdCollapseStart
    ProtectionOff
    .InsertBefore Chr(11)
    ProtectionOn
    End If
    End With
    End Sub
    </pre>


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

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    The only thing I can think of is that if you have other form fields before Date_exp in the same paragraph, you may have to do this in their On Exit macro too - the position of Date_exp might shift if those form fields are edited. If there are no form field before Date_exp in the same paragraph, there is no problem.

  12. #12
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    There are other FormFields in the same paragraph, but according to the end-users I've talked to, the described problem doesn't apply to them, only to this date FormField.
    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> Hans!

  13. #13
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    Ah, I see what you mean now. But I don't think this is much of a problem, because our users are very well trained to jump out of every FormField with a Tab... <img src=/S/innocent.gif border=0 alt=innocent width=20 height=20>

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

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    What I meant was that the Date_exp form field might end up in a different position on the line if form fields before it are modified. You won't catch that with the On Exit macro of Date_exp.

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

    Re: Keep FormField contents on 1 line (WinXP NL / Off2003 NL)

    If the users always tab into and out of Date_exp while editing, it should be OK.

Posting Permissions

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