Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Setting the maximum length of a text form field
I'm creating a form using Word 2003, and one of my text fields needs to have
a maximum length of 30 words. I can only set the maximum length in characters - can I set it to count words? |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Setting the maximum length of a text form field
On Wed, 5 Dec 2007 04:36:00 -0800, PaddyPenfold
wrote: I'm creating a form using Word 2003, and one of my text fields needs to have a maximum length of 30 words. I can only set the maximum length in characters - can I set it to count words? No, the field has no concept of "words". It's characters or nothing. If you want add an exit macro to the field, you could write code that counts the words in the field's result when the user tries to go to the next field, and puts the cursor back into the field after showing a message box. It would be similar to the macro in http://www.word.mvps.org/FAQs/TblsFl...ateFFields.htm. The main problem with this approach is that most users will see a scary antivirus message when they open the form, and some (who have their security level set to High) won't be able to run the macro at all. -- 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. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Setting the maximum length of a text form field
Assuming the field bookmark to be Text,1 running the following macro on exit
from that field should do the trick. Sub MoreThan30() Dim oFld As FormFields Dim sText As String Set oFld = ActiveDocument.FormFields start: sText = oFld("Text1").Result oFld("Text1").Select If Selection.Words.Count 30 Then sText = InputBox("Too many words - reduce to 30 or less", _ "Error", sText) oFld("Text1").Result = sText GoTo start: End If End Sub http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org PaddyPenfold wrote: I'm creating a form using Word 2003, and one of my text fields needs to have a maximum length of 30 words. I can only set the maximum length in characters - can I set it to count words? |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can I change the length of a text form field? | Microsoft Word Help | |||
text form field options maxium length unlimited ? | Microsoft Word Help | |||
Word form fixed length text field that doesn't change formatting? | Microsoft Word Help | |||
Shadow trailing the length of the Frame using Text Form Field? | Microsoft Word Help | |||
Form field default text length | New Users |