Results 1 to 5 of 5

Thread: word count (XP)

  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    word count (XP)

    I have to write a paper of 5,000 words and know how to count the total words in the document. But my superviser wants me to mark in the text every 100th word. Can this be done and, if so, how

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: word count (XP)

    Have you sent this one to Scott Adams (author of Dilbert)? <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

    Microsoft offers a macro on its website to "reliably" check the number of words in the current selection. You could take an educated guess about how big a selection 100 words is, and then use Microsoft's macro to find the boundary. (There should be a link to the download page here in other posts on Word's word count feature).

    If you examine the code of Microsoft's macro, you might be able to automate this process, but it might be tricky to find an efficient way to do it: it's reliable to march through the text one "word" at a time (when you do it that way, you're emulating Ctrl+Shift+RightArrow, so the punctuation will slow your progress) and check again, but that could take a long time in a large document.

    One other question: how can you mark the spot without adding more words? A tiny icon that says 100?

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: word count (XP)

    Here is a crude and simple macro that will put an * every 100 words.
    <pre>Dim counter As Integer
    For counter = 1 To 55
    Selection.MoveRight Unit:=wdWord, Count:=100
    Selection.TypeText Text:=" * "
    Next counter
    </pre>


    I put 55 as the end of the loop to be sure it goes far enough. If that number is too big it just puts some extra * s at the end.
    I imagine this macro treats paragraph marks as words so it may not be completely accurate, but that may not matter much in this context.

    edited by John immediately
    I realise I should add. It runs from the cursor, so be sure the cursor is at the start.
    Regards
    John



  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: word count (XP)

    Unfortunately, if you test using a small number, you'll see that commas and other punctuation are treated as words by this approach. But the way I thought might be too slow isn't so terribly bad, at least testing with a small number:

    Test document:

    [i]Word1 word2, word3 word4. Word5 word6 word7A-word7B word8. Word9

  5. #5
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: word count (XP)

    Hi John,
    You could ensure that the macro starts at the beginning of the document via
    Selection.HomeKey Unit:=wdStory
    You could also eliminate the extra markers with
    For counter = 1 To Int(ActiveDocument.Words.Count / 100)
    More problematic though is the fact that your " * " solution changes the document's formatting and its word count. The user would also need to delete the " * "s if the document was edited after the macro is run. If the text is nominally all the one colour, you could achieve the required result by changing the colour of every 100th word, forcing all other words to the default colour.
    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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