2

I have scoured the Internet and I have found a handful of possible solutions to this issue, but I wanted to ask here as well.

The goal is to click a button, and spell check an entire sheet.

Here's some code

Sub spellCheck()

Sheet1.Cells.CheckSpelling
End Sub

Also, I found this:

Sub SpellCheck()
Dim Checkword As String, Result As Boolean
Checkword = Selection.Value
Result = Application.CheckSpelling(Checkword)
Selection.Offset(0, 1) = Result
End Sub

Any ideas? Neither is working for me. Thanks!

STANGMMX
  • 973
  • 7
  • 18
  • 31
  • To spellcheck an entire workbook. Option Explicit Sub Check_Workbook() Dim wks as Worksheet For each wks in Worksheets Call spellCheck(wks) Next End Sub Sub spellCheck(whichSheet as Worksheet) whichSheet.Cells.CheckSpelling End Sub – Scott Holtzman Aug 21 '12 at 15:08
  • I have it in C# in case you wanna try. http://stackoverflow.com/questions/12120082/excel-spell-check-using-c-sharp/12141489#12141489 – lunchbox Aug 27 '12 at 11:58

5 Answers5

3

You can check the whole workbook by doing something like:

Sub SpellCheck()

For Each sh In Worksheets
    Sheets(sh.Name).Cells.CheckSpelling
Next

End Sub

this will cycle through each sheet in the entire book and run a spellcheck on each one. What I can't figure out yet is how to make the spell checker actually move to the position of the spelling error. So, with the above you just get a list of spelling errors with no context with which to asses them.

CaptElmo
  • 31
  • 2
1

I noticed I just had a typo in my code.

Below works:

Sub spellCheck()

Sheet1.Cells.CheckSpelling

End Sub

But, if anyone knows how to do the entire workbook, I'd be interested in that. Thanks.

STANGMMX
  • 973
  • 7
  • 18
  • 31
  • It looks like you have got the code above for the entire workbook, where instead of Sheet1 you can put For Each and Sheets(sh.Name). – Geographos Feb 26 '20 at 11:05
1

This code will work on selected cells .This will highlight if any spell mistakes in a cell

Dim Myrange As Range
Selection.SpecialCells(xlVisible).Select
For Each Myrange In Selection
    If Application.CheckSpelling(word:=Myrange.Value) = False Then
    Myrange.Font.Color = vbRed
    End If
Next
Sathish Kothandam
  • 1,530
  • 3
  • 16
  • 34
0

OK, so you can use the following command to invoke the toolbar's spellchecker which does move you to the position of the spelling error as long as you have screen updating enabled at the time.

Application.CommandBars("Tools").Controls("Spelling...").Execute

You can use this command embedded in the loop above to loop through the sheets in the workbook and invoke this command on each new sheet.

Cap

CaptElmo
  • 31
  • 2
0

This uses a code snippet from a previous answer to restrict the area used for spellchecking to a specific region. Something I needed to do in a small project. This give the full functionallity of the spellchecker with errors shown in context. The rowNumber is calculated elsewhere.The selection range can be fully controlled elsewhere in your code to suit your particular need. Thought this might help others searching this posting.

 With Sheets("Sheet1")
    slic = CStr(rowNumber)
    .Range("AL3:AN" & slic).Select   
    Application.CommandBars("Tools").Controls("Spelling...").Execute
End With

Thanks to previous posters this solved a problem form me. I am most grateful.