Highlight the word that is misspelled

jjfletcher

Board Regular
Joined
Sep 10, 2008
Messages
152
Hello Everyone,

I have the below code that works great - I wanted to know what changes can be made to the code so the misspelled word is highlighted...

Any thoughts???

Code:
Private Sub CommandButton16_Click()

    Dim xCell As Range
    On Error Resume Next
    With ActiveSheet
        Set xCell = .Cells(.Rows.Count, .Columns.Count)
    End With
    xCell = TextBox2.Text
    xCell.CheckSpelling , , True, 1033
    TextBox2.Text = xCell
    xCell.ClearContents

End Sub


Regards,

John
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I assume that CommandButton16 and TextBox2 are controls on a UserForm. Given that, I don't think it's possible to highlight part of a text in a TextBox. You could flag the word by making it uppercase. Try this:

Code:
Private Sub CommandButton16_Click()
Dim Words As Variant, w As Variant, s As String

    Words = Split(TextBox2.Text)
    For Each w In Words
        If Not Application.CheckSpelling(w) Then w = UCase(w)
        s = s & w & " "
    Next w
    TextBox2.Text = Trim(s)
End Sub
Note that this version eliminates the need for putting the text on the spreadsheet in order to check spelling.
 
Upvote 0
Solution
Hi Eric,

Yes they are controls in a UserForm... Sorry about that!!

Thanks for your suggestion, The UPPER CASE solution seems logical, however it does not enable the Excel System Dictionary popup as in my code.. To bad those words that are spelled wrong cannot be highlighted.

Regards,

John
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top