# WOrd spell check macro (slow and not responding)



## redbridge (Jul 15, 2011)

hi there,
I have loaded the spell check macro from the internet but when the document is big (say 20 pages), the Word 2003 stops responding after some pages. Sometimes, I cannot even use other Office software as it will affect the Word. Is there a limit on the resource? The macro was attached here. I want to use this macro so I can replace the mispelled word automatically and at this time, pick the top choice Word provides.

Sub Auto_Spell() 

Dim myDoc As Document 
Dim SpellSuggs As SpellingSuggestions 
Set myDoc = ActiveDocument 
'********* START THE SPELLING CHECK LOOP ******************** 
Do While myDoc.SpellingErrors.Count >= 1 
'Check to make sure there is at least one spelling error. 
Set SpellSuggs = GetSpellingSuggestions(myDoc.SpellingErrors(1).Text) 
'Get the array of spelling suggestions that Word is offering 
'for the first error in the document. 
If SpellSuggs.Count >= 1 Then 
'If there are any suggestions, then accept the first suggestion. 
myDoc.SpellingErrors(1).Text = SpellSuggs(1) 
Else 
'If there are NO suggestions, then IGNORE the misspelled word. 
'Note: without this step, we will be stuck in an endless loop 
'that will constantly attempt to get suggestions for this word. 
myDoc.SpellingErrors(1).NoProofing = True 
End If 
Loop 
'********* END THE SPELLING CHECK LOOP ********************** End Sub


thanks.


----------



## Corday (Mar 3, 2010)

Where did the macro come from (URL)?


----------



## redbridge (Jul 15, 2011)

it is coming from

MS Word Macro - Run The Spell-Checking Process Using Macros


----------



## macropod (Apr 11, 2008)

Hi redbridge,

Does the document have many spelling errors? Have you checked that your Word installation is OK (Help|Detect & Repair)? I can't see why the code should cause any problems, as such, though it could be made to run much faster (and give feedback via the statusbar on its progress):

```
Sub Auto_Spell()
Dim SBar As Boolean           ' Status Bar flag
Dim TrkStatus As Boolean      ' Track Changes flag
' Store current Status Bar status, then switch on
SBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
' Store current Track Changes status, then switch off
With ActiveDocument
  TrkStatus = .TrackRevisions
  .TrackRevisions = False
End With
' Turn Off Screen Updating
Application.ScreenUpdating = False
Dim myDoc As Document, SpellSuggs As SpellingSuggestions, i As Long
Set myDoc = ActiveDocument
With myDoc
  If .SpellingErrors.Count = 0 Then
    MsgBox "No spelling errors found", vbExclamation
    Exit Sub
  End If
  'Check for spelling errors
  For i = .SpellingErrors.Count To 1 Step -1
    StatusBar = i & " spelling errors remaining"
    'Check to make sure there is at least one spelling error.
    Set SpellSuggs = GetSpellingSuggestions(myDoc.SpellingErrors(i).Text)
    'Get the array of spelling suggestions that Word offers
    'for the current error.
    If SpellSuggs.Count > 0 Then
      'If there are any suggestions, then accept the first suggestion.
      With myDoc.Content.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Format = False
        .MatchAllWordForms = False
        .MatchWholeWord = True
        .Text = myDoc.SpellingErrors(i).Text
        .Replacement.Text = SpellSuggs(1)
        .Execute Replace:=wdReplaceAll
      End With
    Else
      'If there are NO suggestions, then IGNORE the misspelled word.
      'Note: without this step, we will be stuck in an endless loop.
      myDoc.SpellingErrors(i).NoProofing = True
    End If
    i = .SpellingErrors.Count + 1
  Next
End With
' Clear the Status Bar
Application.StatusBar = False
' Restore original Status Bar status
Application.DisplayStatusBar = SBar
' Restore original Track Changes status
ActiveDocument.TrackRevisions = TrkStatus
' Restore Screen Updating
Application.ScreenUpdating = True
MsgBox "Spellcheck Finished", vbExclamation
End Sub
```


----------



## redbridge (Jul 15, 2011)

thanks. I am going to try it later today. My document can be huge (over 200 pages?) and can contain quite a bit of typo (it is a data capture operation) and it contains both English and French words/phrase. Since in the interactive mode, Word can identify the languages and use the appropriate dictionary, can I assume that this macro will run like that by correcting both French and English spelling mistakes?


----------



## macropod (Apr 11, 2008)

Hi redbridge,

I would expect the macro to work the same, _provided _the errors being corrected via a given Find/Replace operation are all in the same language. For example, if 'qui' is an error in English, but not in French, and the correction offered for the English error is 'quick', the Find/Replace would replace the French text as well.


----------



## redbridge (Jul 15, 2011)

no, it is still hanging with the new one. If you want, I can send you the document so you can take a look.

thanks

PS: How do I do private mail?

redbridge


----------



## macropod (Apr 11, 2008)

Hi redbridge,

You should be able to attach the document to a post. You may need to zip the file first, though.

BTW, which Word version are you using?


----------



## redbridge (Jul 15, 2011)

I have attached the file in zipped format. I am using Word 2007 with Vista at work. I am using Word XP with Windows XP at home.


----------



## macropod (Apr 11, 2008)

I ran my version of the macro against your test document. It took about 2 seconds to complete. This is with Word 2010 on Win 7.


----------



## redbridge (Jul 15, 2011)

that should be over 1,000 errors or something, take 2 seconds?? It took me 2 seconds to *correct* one error (i.e. the counter decreases by 1). Is it because all the words are in uppercase in the document which was not detected as errors?

I tried again this afternoon by removing all the French phrases. Also, I tried not to zoom out (i was zooming out to 10% in order to see the words being corrected i.e. showing the red underline being removed automatically) and it ran!!!! But it took several minutes. But when I went back to the original file (with English/French), it hangs again even I did not zoom in.

scratching head..


----------



## macropod (Apr 11, 2008)

Hi redbridge,

I can only tell you what happens with the test file you supplied. I'd be reluctant to speculate about other files. Going through the document manually, there are only 20 'errors' in the file.


----------

