Code to run a Spell check

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Code to run a Spell check

Post by ABabeNChrist »

What might be the code to run a spell check on the open sheet

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Code to run a Spell check

Post by Don Wells »

ABabeNChrist wrote:What might be the code to run a spell check on the open sheet
Try:

Code: Select all

    Cells.Select
    Selection.CheckSpelling SpellLang:=1033
Regards
Don

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Code to run a Spell check

Post by HansV »

You can use

Cells.CheckSpelling

You can specify another language than the default one:

Cells.CheckSpelling SpellLang:=msoLanguageIDSpanish
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Code to run a Spell check

Post by HansV »

Don Wells wrote:Try:

Code: Select all

    Cells.Select
    Selection.CheckSpelling SpellLang:=1033
There's no need to select the cells.
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Code to run a Spell check

Post by ABabeNChrist »

Thank you Don and HansV
Thats a pretty small piece of code. lol

Code: Select all

Cells.CheckSpelling
But it works good

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Code to run a Spell check

Post by Don Wells »

HansV wrote: There's no need to select the cells.
I find that if cells are selected, when a spelling error is found, the cell in question is identified in the 'Name Box'. Otherwise on a large sheet the user is left to guess at the location and context.
Regards
Don

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Code to run a Spell check

Post by HansV »

It doesn't work that way for me in Excel 2007...
Best wishes,
Hans

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Code to run a Spell check

Post by Don Wells »

HansV wrote:It doesn't work that way for me in Excel 2007...
I'm still running 2003.
Regards
Don

User avatar
mbarron
2StarLounger
Posts: 112
Joined: 25 Jan 2010, 20:19

Re: Code to run a Spell check

Post by mbarron »

I'm running 2003 as well and I do not see a cell reference in the Name Box if I do the spell check in code. I do get a cell reference if I run the spell checker manually.

steveh
SilverLounger
Posts: 1952
Joined: 26 Jan 2010, 12:46
Location: Nr. Heathrow Airport

Re: Code to run a Spell check (Excel 2003 SP3)

Post by steveh »

ABabeNChrist wrote:What might be the code to run a spell check on the open sheet
Morning

Out of interest I recorded a new macro and used the spell check on a work sheet into which a had typed a couple of dozens of lines of text and made sure some were spelt wrong, and I got this

Sub SpellIt()
'
' SpellIt Macro
' Macro recorded 28/02/2010 by Steve
'
' Keyboard Shortcut: Ctrl+k
'
Cells.CheckSpelling SpellLang:=2057
End Sub

When I tried it on some text that had again been spelt wrong it run exactly as the spell checker normally does with the dialog offering me alternatives. Like Don I too get = and a number and I guess that the difference is 1033 may be English US and 2057 may be English proper ( :grin: ). I am off to Google to see if I can find out.

:blush: Editted: Reason - to correct spelling mistake!!
Steve
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Code to run a Spell check

Post by HansV »

If you omit the SpellLang:=..., Excel will use the default language for spell checking.

Don Wells meant that the offending cell is selected, and hence its address (such as D3) displayed on the left of the formula bar when a spelling error is found. This doesn't happen if I run a spell check in code.
Best wishes,
Hans

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Code to run a Spell check

Post by Don Wells »

HansV wrote:If you omit the SpellLang:=..., Excel will use the default language for spell checking.

Don Wells meant that the offending cell is selected, and hence its address (such as D3) displayed on the left of the formula bar when a spelling error is found. This doesn't happen if I run a spell check in code.
I don't recall smoking anything unusual yesterday. Here is what happens when a spelling error is detected:
  • The entire sheet is selected;
    Cell 'A1' is active;
    The Name Box identifies the cell which was active when the macro was run; and
    The Spell Check dialog box is visible, identifying the spelling error.
I suspect that yesterday I introduced the spelling error, and left the offending cell active when I ran the macro.

My humblest apologies to all for any confusion. :bagged:
Regards
Don

Mustaq
NewLounger
Posts: 1
Joined: 09 Jun 2022, 07:12

Re: Code to run a Spell check

Post by Mustaq »

Supported Tags: It supports all HTML elements.

Syntax :
Syntax for spellcheck attribute in an input field in html:

<input type="text" spellcheck="value">
Syntax for spellcheck in a textarea field in html:

<textarea type="text" spellcheck="value"></textarea>

<!DOCTYPE html>
<html>
<body>
<h3>Example of Disabling SpellCheck</h3>
<form>


<p>
<input type="text" spellcheck="false">
</p>




<p>
<textarea spellcheck="false"></textarea>
</p>


<button type="reset">Reset</button>
</form>
</body>
</html>