WD: WordBasic ToolsWordCount Command Returns Incorrect Values

Last reviewed: November 17, 1997
Article ID: Q176750
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a

SYMPTOMS

When you use the Microsoft Word WordBasic ToolsWordCount command, the number of Words returned may be incorrect based upon the current selection.

CAUSE

The Tools Word Count feature in Word must be updated before an accurate count will appear.

WORKAROUND

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.

The following example WordBasic macro obtains the values of the ToolsWordCount dialog, updates the dialog, again retrieves the updated values and displays the correct number of selected Words.

Select the text to return a word count for prior to running the following macro.

   Sub Main
      ' Define the dialog record.
      Dim dlg as ToolsWordCount
      GetCurValues dlg
      ' Update the dialog values.
      ToolsWordCount dlg
      ' Retrieve the updated values.
      GetCurValues dlg
      ' Display the number of selected words.
      MsgBox dlg.Words
   End Sub

MORE INFORMATION

For additional information, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q97593
   TITLE     : Word For Windows Reports Incorrect Number of Words in
               Document

   ARTICLE-ID: Q92929
   TITLE     : WD: Macros to Count the Number of Document Paragraphs and
               Lines
   ARTICLE-ID: Q114180
   TITLE     : WD: Word Count Does Not Count Spaces

   ARTICLE-ID: Q173707
   TITLE     : OFF97: How to Run Sample Code from Knowledge Base Articles

Keywords          : kbmacroexample macword ntword winword wordnt
Version           : MACINTOSH:6.0,6.0.1,6.0.1a; WINDOWS:6.0,6.0a,6.0c,7.0,7.0a
Platform          : MACINTOSH WINDOWS
Issue type        : kbhowto
Solution Type     : kbworkaround


================================================================================


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.