Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Restricting space used! (WinXP/Word2003)

    I think I might have an impossible task here, but I've got to try anyway!

    My favourite form (see several recent posts!) is set up in tables, is protected and uses formfields to put in the info. On one page we have a particular bit of the form that needs to all stay on one page - and one particular formfield that tends to have very long content, and therefore needs to be restricted to a maximum of 10 lines.

    So my question is, is there any way of restricting the content of a form field in a table to no more than 10 lines (even if some of the lines are blank returns), while not having the space there unless it's used?

    The formfield is in a full width row on its own, and with roughly 130 characters to a line I have restricted the formfield to a max of 1300 characters, but blank lines (just returns) would only be one character. I've tried restricting the height of the table row but there doesn't seem to be a 'max height' option, only 'at least' and 'exactly' (we don't want the space there if it's not being used).

    Any suggestions would be gratefully received!

    Sigh. Why can't these people ask for some easy requirements for a change?!
    Beryl M


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

    Re: Restricting space used! (WinXP/Word2003)

    Added: oops - this macro is useless; it only checks the number of paragraph marks, not the number of lines. Sorry!

    You could use an Exit macro for the formfield to issue a warning if the field contains more than 10 lines:

    Sub Text1Exit()
    Dim strText As String
    With ActiveDocument.FormFields("Text1") ' replace with appropriate name
    strText = .Result
    If Len(strText) - Len(Replace(strText, vbCr, vbNullString)) > 9 Then
    MsgBox "Warning! Too many lines!", vbCritical
    End If
    End With
    End Sub

    For a far more elaborate version by Jefferson Scher, see the long thread starting at <post#=132,458>post 132,458</post#>.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Restricting space used! (WinXP/Word2003)

    Added - your 'added' crossed mine in the post - but don't worry, the other suggestion does the trick!
    Added again - ignore comment about lack of explanation - just found where they hid it!!


    Hi Hans, thanks for this!

    If I'm reading your 'mini' version right, it counts lines created by returns, yes? - at least, when I tested it the answers seemed to correlate to that - but unfortunately I've no way of telling whether the user has used returns or just put one long para, so I can't use that one.

    However, Jefferson's 'long' version does seem to do what I want, so many thanks for pointing me to his post!

    It also introduced me to a whole new set of commands in VBA (information) that I hadn't discovered before, so I'll have to investigate it further - however, it is annoying that the VBA Help merely says the command 'Information' is available and gives a couple of examples! Nowhere I can find does it list the available commands and their uses that go with it, such as wdFirstCharacterLineNumber, the one Jefferson used!

    Typical M$, huh?! <img src=/S/sigh.gif border=0 alt=sigh width=15 height=15>

    Anyway, thanks again <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    Beryl M


Posting Permissions

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