Spell Checker in a ActiveX Textbox issue.

wdurrant

New Member
Joined
Mar 21, 2022
Messages
20
Office Version
  1. 365
Platform
  1. Windows
I found some code I found at How to apply spell check in textbox? to check for misspelled words in an ActiveX textbox and all-in-all it works great except if it finds a misspelled word and you click on "Ignore Once" , "Ignore All" or "Cancel," it seems to go into this endless loop. After you hit Cancel about 10 times, the spell checker window finally goes away. I am not a VBA guru by any means. Any reasons why this may be happening?

Dim xObject As Object
Dim xCell As Range
On Error Resume Next
Set xCell = ActiveSheet.Cells(ActiveSheet.Rows.Count, ActiveSheet.Columns.Count)
If ActiveSheet.OLEObjects.Count > 0 Then
For Each xObject In ActiveSheet.OLEObjects
xCell = xObject.Object.Text
xCell.CheckSpelling , , , 1033
xObject.Object.Text = xCell
Next
End If
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
How many controls do you have in the active sheet? It will run spell check separately for each control. You run spell check on the first control. Then if you hit Cancel, it runs spell check on the next control. Then if you hit Cancel, it runs spell check on the next control. Until it has gone through all the controls.

Is this supposed to be a general-purpose macro that you can use for any sheet? Or do you have a specific sheet in mind that you need to check?
 
Upvote 0
That makes sense. I have several controls on just one sheet but I only want it to check the one textbox that I have.
 
Upvote 0
T
How many controls do you have in the active sheet? It will run spell check separately for each control. You run spell check on the first control. Then if you hit Cancel, it runs spell check on the next control. Then if you hit Cancel, it runs spell check on the next control. Until it has gone through all the controls.

Is this supposed to be a general-purpose macro that you can use for any sheet? Or do you have a specific sheet in mind that you need to check
How many controls do you have in the active sheet? It will run spell check separately for each control. You run spell check on the first control. Then if you hit Cancel, it runs spell check on the next control. Then if you hit Cancel, it runs spell check on the next control. Until it has gone through all the controls.

Is this supposed to be a general-purpose macro that you can use for any sheet? Or do you have a specific sheet in mind that you need to check?
How many controls do you have in the active sheet? It will run spell check separately for each control. You run spell check on the first control. Then if you hit Cancel, it runs spell check on the next control. Then if you hit Cancel, it runs spell check on the next control. Until it has gone through all the controls.

Is this supposed to be a general-purpose macro that you can use for any sheet? Or do you have a specific sheet in mind that you need to check?
 
Upvote 0
Then instead of code that loops every control, use this (also I recommend marking your code by selecting it then clicking the VBA button--it preserves the spacing and color codes keywords)

VBA Code:
Dim xCell As Range
Set xCell = ActiveSheet.Cells(ActiveSheet.Rows.Count, ActiveSheet.Columns.Count)
xCell = TextBox1 ' update with your text box's name
xCell.CheckSpelling , , , 1033
TextBox1.Text = xCell
 
Upvote 0
Solution
Don't know if I need to start a new thread, but would you know how to highlight the misspelled word. Its not a huge deal, but it saves time trying to find the misspelled word and choosing the correct word to replace it with.
 
Upvote 0
When you use .SpellChecking you put yourself in the hands of the built-in spell checker and you don't have any control over how it works. It is the same code as if you invoked spell check from the worksheet. To highlight the word you would have to write the spellcheck logic yourself from scratch. I do agree this is a weakness in how Excel spell check works.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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