WD6X: AppleScript Example: Count Command

Last reviewed: November 17, 1997
Article ID: Q125581
The information in this article applies to:
  • Microsoft Word for the Macintosh, version 6.0, 6.0.1, 6.0.1a

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.

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--.

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
    


Additional query words: Apple Script
Keywords : kbmacroexample macword word6 kb3rdparty kb3rdparty
Version : MACINTOSH:6.0,6.0.1,6.0.1a
Platform : MACINTOSH
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.