Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
PaddyPenfold PaddyPenfold is offline
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I change the length of a text form field? karenb316 Microsoft Word Help 1 September 22nd 06 10:42 PM
text form field options maxium length unlimited ? reecedeg Microsoft Word Help 1 February 27th 06 03:53 AM
Word form fixed length text field that doesn't change formatting? Colin Microsoft Word Help 3 January 25th 06 07:35 PM
Shadow trailing the length of the Frame using Text Form Field? bmac Microsoft Word Help 0 November 2nd 05 06:05 PM
Form field default text length BostonHR New Users 2 October 26th 05 09:40 PM


All times are GMT +1. The time now is 07:46 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"