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 / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Limiting the Number of Words

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
klav - 25 Jan 2007 13:27 GMT
I would like to limit the number of words in a particular section of a
document to 90 words. The document is not set up as a form. Is there a way to
do this?  

If that is not possible, I would at least like to alert the user how many
words are contained in this particular section. I know there is a {numwords}
field but can this be used only for one specific section?  Also, do you have
any suggestions for implementing this -- I would like the user to know as
they are entering/deleting text how many words have been entered rather than
having a macro that executes a field update when they attempt to save or
close the document.  Thanks in advance for your help.
Jean-Guy Marcil - 01 Feb 2007 20:37 GMT
klav was telling us:
klav nous racontait que :

> I would like to limit the number of words in a particular section of a
> document to 90 words. The document is not set up as a form. Is there
> a way to do this?

No.

> If that is not possible, I would at least like to alert the user how
> many words are contained in this particular section. I know there is
[quoted text clipped - 4 lines]
> a field update when they attempt to save or close the document.
> Thanks in advance for your help.

This would take a lot of  heavy and complicated code in class and standard
modules....

You could, at the start of the said section, include a MacroButton field:
   {MACROBUTTON SectionWordCount Count}
       (where the {} are typed in by doing CTRL-F9)
and use this macro:

'_______________________________________
Sub SectionWordCount()

'-1 to remove the word form the macrobutton field
MsgBox
CStr(Selection.Sections(1).Range.ComputeStatistics(wdStatisticWords) - 1)

End Sub
'_______________________________________

Now the user just has to double click on the field to get the word count.

You could link the macro to a toolbar button instead, in which case, remove
the "- 1" from the code and tell the user to place the cursor in the
appropriate section before clicking on the button.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
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.