WD: WordBasic ToolsWordCount Command Returns Incorrect Values

ID: Q176750

The information in this article applies to:

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          : wordnt kbmacroexample winword ntword macword 
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

Last Reviewed: February 13, 1999