Consulting

Results 1 to 4 of 4

Thread: Solved: count word in selection

  1. #1

    Solved: count word in selection

    i m trying this below code but getting error saying 'type mismatch'
    [VBA]
    MsgBox ActiveDocument.Words(Selection.Words(1))
    [/VBA]

  2. #2
    VBAX Mentor Marcster's Avatar
    Joined
    Jun 2005
    Posts
    434
    Location
    There's a macro from Microsoft you can download:
    Word 2000 Tool: Selection Word Count Macro:
    http://www.microsoft.com/downloads/d...displaylang=EN

    It allows you to see the code in the VBE so as to work out how it works.

    If the above is abit overkill, or you don't have Word 2000, let me know and i'll post a macro to display what you require.

    HTH,
    Marcster.

  3. #3
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    If you want a count of the number of words in the current Selection you need to use the Words property of the Range of the Selection.

    Try:
    [vba]MsgBox Selection.Range.Words.Count[/vba]

  4. #4
    Thankyou Gerry, Marcster. It is solved.

Posting Permissions

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