PDA

View Full Version : Solved: count word in selection



ilyaskazi
11-16-2005, 05:16 AM
i m trying this below code but getting error saying 'type mismatch'

MsgBox ActiveDocument.Words(Selection.Words(1))

Marcster
11-16-2005, 05:42 AM
There's a macro from Microsoft you can download:
Word 2000 Tool: Selection Word Count Macro:
http://www.microsoft.com/downloads/details.aspx?FamilyID=63B96F95-0C6A-4839-9ABC-ED9883E12E42&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.

fumei
11-16-2005, 09:02 PM
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:
MsgBox Selection.Range.Words.Count

ilyaskazi
11-16-2005, 10:03 PM
Thankyou Gerry, Marcster. It is solved.