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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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