Spellcheck a single word in Excel function
excel, spell-checking, vba
Solution
Like I mentioned in my comment it works.
Option Explicit
Sub Sample()
MsgBox SpellCheck("hello") '<~~ Returns True
MsgBox SpellCheck("daasd") '<~~ Returns False
End Sub
Function SpellCheck(SomeWord As String) As Boolean
SpellCheck = Application.CheckSpelling(SomeWord)
End Function
`Application.CheckSpelling` will not correct or offer to correct a misspelled word, it only returns `True` or `False`
I tested
`?Application.CheckSpelling("hello")`
in immediate window and it returned `True`
EDIT: Calling `Application.CheckSpelling` from UDF would always return `False`. Last time I checked, it was still a bug and there was no way around it. If there is a recent update on that then I am not aware of it. :)
MORE EDIT
Here is your function slightly modified which will work as a UDF as well :)
Got the idea from this link
Function SpellCheck(rng As Range) As Boolean
Dim oxlAp As Object
Set oxlAp = CreateObject("Excel.Application")
SpellCheck = oxlAp.CheckSpelling(rng.Value)
oxlAp.Quit
Set oxlAp = Nothing
End Function
Problem
This little Excel VBA function always returns false, no what word is passed in. ``` Function SpellCheck(SomeWord As String) SpellCheck = Application.CheckSpelling(SomeWord) End Function ``` In fact, in the IDE I can verify that Application.CheckSpelling("hello") fails, though the Excel spellchecker does detect misspellings. What I'm trying to do is get a T/F value for each word if it is spelled correctly.