none
Highlight all the spelling that are change or modified during Spelling and Grammer Check (F7) in microsoft word using VBA RRS feed

  • Question

  • Hi,

    I had a requirement in MS word to Highlight Only those words in the document that are change using "Change" or "Change All" option in Spelling and Grammar (F7) dialogbox. I will be using VBA. Is it possible? if yes then please help!

    Thanks in Advance

    Rit

    Wednesday, February 19, 2014 8:01 PM

Answers

  • You can find all the options for the SpellingAndGrammar dialog box at: http://msdn.microsoft.com/en-us/library/ff845471.aspx. Neither the 'Change' nor the 'Change All' button is catered for.

    As a workaround, you could automate the SpellingAndGrammar function to highlight all spelling errors then, having done your corrections, automate the SpellingAndGrammar function a second time to un-highlight all spelling errors. Whatever remains highlighted is what you changed the first time around.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by Marvin_Guo Wednesday, February 26, 2014 2:06 AM
    Sunday, February 23, 2014 4:24 AM

All replies

  • Hi,

    As far as I know, we can’t highlight misspelled words which have been changed, but I found some workaround to highlight all of spelling error collection, and then using change function to correct words, A Spelling Errors collection that represents the words identified as spelling errors in the specified document or range.

    Here is a VBA sample code for your reference:

    Sub HighlightSpellErrors()
    
      'Highlight all misspelled words.
    
      Dim rng As Range
    
      Dim docSourse As Document
    
      Set docSource = ActiveDocument
    
      For Each rng In docSource.SpellingErrors
    
      rng.Find.Highlight
    
        rng.Font.Color = wdColorRed
    
      Next
    
    End Sub
    

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 21, 2014 9:44 AM
  • Thanks Mark for the code

    I am trying to access "Spelling & grammar" dialog box buttons. Can access to the "Change or Change All" button of the dialog box? We can trap the event for button pressed & can highlight the misspelled word that are corrected. Appreciate your effort.

    Friday, February 21, 2014 6:47 PM
  • You can find all the options for the SpellingAndGrammar dialog box at: http://msdn.microsoft.com/en-us/library/ff845471.aspx. Neither the 'Change' nor the 'Change All' button is catered for.

    As a workaround, you could automate the SpellingAndGrammar function to highlight all spelling errors then, having done your corrections, automate the SpellingAndGrammar function a second time to un-highlight all spelling errors. Whatever remains highlighted is what you changed the first time around.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by Marvin_Guo Wednesday, February 26, 2014 2:06 AM
    Sunday, February 23, 2014 4:24 AM
  • Thanks Paul for valuable suggestion. Could you please help providing the code for same. It will be much helpful for me.
    Monday, February 24, 2014 7:20 PM
  • You could use a macro like:

    Sub SpellingErrorHighlighter()
    Dim oSpErrors As ProofreadingErrors
    Dim oSpError As Word.Range
    Set oSpErrors = ActiveDocument.Range.SpellingErrors
    For Each oSpError In oSpErrors
      With oSpError
        If .HighlightColorIndex = wdBrightGreen Then
          .HighlightColorIndex = wdNoHighlight
        Else
          .HighlightColorIndex = wdBrightGreen
        End If
      End With
    Next
    End Sub

    Simply run it before and after doing your spell-check.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Monday, February 24, 2014 9:56 PM