Help and Support

WD6X: AppleScript Example: Count Command

Article ID:125581
Last Review:November 21, 2006
Revision:1.1
This article was previously published under Q125581
On This Page

SUMMARY

The information in this article discusses the following AppleScript event:
Count
This event is found in the Core Suite of Word's Event Dictionary.

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Back to the top

MORE INFORMATION

The Core Suite contains events that an application should support to facilitate easy, intuitive communications between the application and the system software. System 7.0 was the first operating system to support these events.

The Count command is used to count the number of objects (words, paragraphs, and so on) in a document. The result is displayed as an integer in "the result" window of AppleScript.
   Count 'something' [Each] 'type'
				
The Each argument tells the Count command what to count, as in --Count each word-- or --Count each paragraph--.

Back to the top

Example

The following AppleScript script examples shows two scripts that use the Count command to count the number of words in a document. These scripts do the following:

1.Open the document named "MyWordFile."
2.Count the number of words in the document.
      tell application "Microsoft Word"
         open "MyWordFile"
         Count words in window 1
      end tell

      tell application "Microsoft Word"
         open "MyWordFile"
         Count each word in window 1
      end tell
						

Back to the top


APPLIES TO
Microsoft Word 6.0 for Macintosh
Microsoft Word 6.01 for Macintosh

Back to the top

Keywords: 
kb3rdparty kbinfo kbmacroexample KB125581

Back to the top

Article Translations

 

Other Support Options

  • Contact Microsoft
    Phone Numbers, Support Options and Pricing, Online Help, and more.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.