Consulting

Results 1 to 2 of 2

Thread: Count words with VBA

  1. #1
    VBAX Regular
    Joined
    Nov 2020
    Location
    Swansea,South Wales,UK
    Posts
    24
    Location

    Count words with VBA

    Hi all,
    Someone asked on another forum if they could count words in Access as is shown in Word in the status bar.?

    Besides using Split(), I was thinking, you could use Word to do it?

    So I pasted some text and then used ActiveDocument.Words.Count to display the count, which was 75, yet the status bar shows words as 69.

    This was a new document and a simple copy and paste.

    What could cause the discrepancy?

    TIA

    Edit: A Split() on a single space actually produces 69 ? Ubound being 68.

  2. #2
    VBAX Regular
    Joined
    Nov 2020
    Location
    Swansea,South Wales,UK
    Posts
    24
    Location
    Found out why.

    Need to use ActiveDocument.Range.ComputeStatistics(wdStatisticWords) to get matching number to status bar

    https://support.microsoft.com/en-us/...a-9da4ca22e3ff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •