Results 1 to 6 of 6

Thread: Sentence length

  1. #1
    Lounger
    Join Date
    Mar 2010
    Location
    South Wales
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I need to measure sentence lengths in Word for an online article I am writing. The only option in Word that I could find notifies if the sentence is over 60 words, but I need to know which sentences are over 20. Has anyone come across a facility in Word or has a macro that would do this please?

    Regards

    Tony

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    A macro can highlight the longer sentences like this...
    Code:
    Sub temp1()
      Dim i As Integer
      For i = 1 To ActiveDocument.Sentences.Count
        If ActiveDocument.Sentences(i).Words.Count > 19 Then
          ActiveDocument.Sentences(i).HighlightColorIndex = wdBrightGreen
        End If
      Next i
    End Sub
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Lounger
    Join Date
    Mar 2010
    Location
    South Wales
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Andrew, will forward the macro text to our production manager.

  4. #4
    Lounger
    Join Date
    Mar 2010
    Location
    South Wales
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Works brilliantly. Can you write one to remove the bright green highlighting too please? Cheeky I know, but you gotta be!

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    This is the sledgehammer approach which removes all highlighting from the file - including the green that was applied by the previous macro.

    Sub RemoveHilites()
    ActiveDocument.Range.HighlightColorIndex = wdNoHighlight
    End Sub
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  6. #6
    Lounger
    Join Date
    Mar 2010
    Location
    South Wales
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cheers Andrew, job's a goodun! )

Posting Permissions

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