WD: WordBasic ToolsWordCount Command Returns Incorrect Values

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:

Q97593 Word For Windows Reports Incorrect Number of Words in Document
Q92929 WD: Macros to Count the Number of Document Paragraphs and Lines
Q114180 WD: Word Count Does Not Count Spaces
Q173707 OFF97: How to Run Sample Code from Knowledge Base Articles

Additional query words:

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: January 3, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.