Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CheckSpelling not working

Status
Not open for further replies.

N1GHTEYES

Technical User
Jun 18, 2004
771
GB
Hi All,

I want to use the Application.CheckSpelling() method in Excel. I've implemented a user function like this:

Public Function chkspl(wrd As String) As Boolean
chkspl = Application.CheckSpelling(wrd)
End Function

The problem is it does not seem to work. Whatever input I give it, whether I explicitly enter a text string or a cell reference holding a string, it always returns FALSE even when the word being checked is perfectly valid (e.g. "table", "red" - hardly obscure words).

I'm running in XP Pro and using Office 2003.

Any suggestions?

Tony
 
I've also checked this on another machine running Office 97 and I get exactly the same problem.
 
OK, this is getting weird.

The checkspelling method seems to work in a macro but not a userfunction. Am I doing something dumb here?

In cell A1 I type the word "table". In cell B1 I enter my spellchecking user function, with the target set to cell A1. Here is the userfunction:

Code:
Public Function chkspl(Target As Range) As Boolean
    Dim strwrd As String
    strwrd = Trim(Target.Text)
    chkspl = Application.CheckSpelling(strwrd)
End Function
This returns FALSE in cell B1.

Now, instead, if I wite a macro to do pretty much the same thing when the sheet selection changes, it works fine. Here is the code:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim strwrd As String
    strwrd = Trim(Target.Text)
    Cells(1, 2) = Application.CheckSpelling(strwrd)
End Sub

If I enter "table" in cell A1, then click out of it and then click back into it (to activate the above code on cell A1), it returns TRUE in cell B1. To check it was actually working, I entered "whjeg" in cell A1 and repeated the clicking out & clicking back in to cell A1. It then sets B1 to FALSE - as you'd expect.

Does anyone have any idea what is going on? Does anyone else get this result - or is it something weird about my setup?

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top