Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Location
    Efrat, Israel
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    counting letters macro (Word XP)

    Hi,

    I am looking for a macro that will count the number of occurrences for every letter (not numbers and symbols), in a selected area of text. Because I

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: counting letters macro (Word XP)

    The following macro is not meant as a finished product, but as a starting point; you should modify it to suit your needs. It will count the number of occurrences of all characters in the range 0 ... 255 (so it doesn't count Unicode chars), and create a table in a new document with the count of upper case and lower case letters.

    Sub CountOccurrences()
    Dim i As Long
    Dim CharCount(1 To 255) As Long

    ' Loop through characters in selection
    For i = 1 To Selection.Characters.Count
    CharCount(Asc(Selection.Characters(i))) = CharCount(Asc(Selection.Characters(i))) + 1
    Next i

    ' New document
    Documents.Add
    ' Create table
    ActiveDocument.Tables.Add Selection.Range, 1, 2

  3. #3
    New Lounger
    Join Date
    Jul 2002
    Location
    Efrat, Israel
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: counting letters macro (Word XP)

    Dear Hans

    Thank you, thank you. I have added the high ASCII I need and it works like a Swiss Watch.

    All the Best

    Mordy

Posting Permissions

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