Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Page Layout / February 2004

Tip: Looking for answers? Try searching our database.

FIxed number of words in a cell or text box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Harry Hudini - 10 Feb 2004 14:42 GMT
Is there a way that you can tell word to limit the number of words in a cell
or a textbox ?

We have a template that is used to send an advert to the printers, and the
users that fill it out are ALWAYS going over the number of words allowed,
which costs us money.

I am looking for a way to limit the user so that they can only enter the
correct number of words ?

Olly

--
________________________________________________
ADSSupport.net
http://www.adssupport.net
Dedicated free Active Directory ServicesT support

email: oliver.marshall@nospam@adssupport.net
Suzanne S. Barnhill - 10 Feb 2004 19:57 GMT
You can limit the number of characters in a text form field. You can limit
the size of a table cell or text box.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Signature

Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


> Is there a way that you can tell word to limit the number of words in a cell
> or a textbox ?
[quoted text clipped - 15 lines]
>
> email: oliver.marshall@nospam@adssupport.net
Jay Freedman - 11 Feb 2004 02:37 GMT
Hi, Olly,

I don't know of any way to prevent people from typing any number of
words into a cell, but you can prevent them from saving or printing
the document while there are too many words. That might solve your
problem.

To do this, you need a series of macros in the template used to base
the documents. Each macro needs a specific name that will cause it to
intercept one of Word's built-in commands -- File > Print, File >
Save, File > Save As, and so on. To intercept the Print commands you
need to write FilePrint and FilePrintDefault.  To intercept the Save
commands you need to write FileSave, FileSaveAs and FileSaveAll.
There's more about this at
http://word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm.

As an example, the macro for FileSaveAs would look something like this
(but adjusted for the table number and row/column as necessary):

Public Sub FileSaveAs()
   Const MaxWords = 60 ' change as needed
   Dim CountWords As Long
   Dim CellRange As Range
   
   ' if there are no tables, don't test
   If ActiveDocument.Tables.Count > 0 Then
       ' check the cell in row 1, column 2 of
       ' the first table in the document
       ' (change this as needed)
       Set CellRange = ActiveDocument.Tables(1) _
           .Cell(Row:=1, Column:=2).Range
           
       ' don't include the end-of-cell marker
       CellRange.MoveEnd unit:=wdCharacter, Count:=-1
       
       ' get the number of words
       CountWords = CellRange.ComputeStatistics(wdStatisticWords)
       
       ' if too many, refuse to save
       If CountWords > MaxWords Then
           MsgBox "The cell contains " & CountWords & _
               " words. The maximum is " & MaxWords & _
               " words."
           Exit Sub
       End If
   End If
   
   ' It passed the test, so save
   Dialogs(wdDialogFileSaveAs).Show
End Sub

>Is there a way that you can tell word to limit the number of words in a cell
>or a textbox ?
[quoted text clipped - 7 lines]
>
>Olly

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://www.mvps.org/word
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.