Spell Check problem

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
I have this code for Spell check, it works fine except when the information inputted in the text box is longer than the textbox can show at once (if that makes sense?). I get a type mismatch error.

The code sends the information to a hidden sheet ("Spelling") runs the spell check and then replaces the text in the textboxes with the corrected text.

Code:
Private Sub cmdSpellCheck_Click()
Dim SpellCheck  As String, _
    SpellCheck1 As String
If (Application.CheckSpelling(txtDetails.Text) = True) And (Application.CheckSpelling(txtOther.Text) = True) Then
MsgBox "Spell check returned no errors"
Else
SpellCheck = txtDetails.Text
SpellCheck1 = txtOther.Text
Application.Worksheets("Spelling").Cells(1, 1).Value = SpellCheck
Application.Worksheets("Spelling").Cells(2, 1).Value = SpellCheck1
'Now Check spelling
Worksheets("Spelling").CheckSpelling AlwaysSuggest:=True
txtDetails.Text = ThisWorkbook.Worksheets("Spelling").Cells(1, 1).Text
txtOther.Text = ThisWorkbook.Worksheets("Spelling").Cells(2, 1).Text
End If
End Sub

Is there anything in my code which I could change, or is it to do with the properties of the multiline textbox?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Nope, it's already set to 0

Even stranger is that the same problem does not occur for the txtOther textbox. Despite any non appearance properties being exactly the same other than tab index

The error occurs on the line

If (Application.CheckSpelling(txtDetails.Text) = True) And (Application.CheckSpelling(txtOther.Text) = True) Then
 
Upvote 0
Ah, no that's a lie, it only works on txtother to a certain limit (I'm guessing the same number of characters as txtOther is smaller than txtDetails).

Maybe the problem is to do with the max number of characters a cell can hold rather than the textbox?
 
Upvote 0
Cells can hold 32,767 characters although the Text property will only return the first 1024. Do you have more characters than this?
 
Upvote 0
Over each of the 4 bits, as follows

txtDetatils.Text = "If (Application.CheckSpelling(txtDetails.Text) = True) An...

True = True

txtOther.Text = ""

True = True
 
Upvote 0
I'm thinking that as a workaround I could split the text in the textbox, so that the first 255 characters are sent to cell(1,1) then the next 255 to cell(1,2) and so on

Just trying to get my head around doing that.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,843
Members
452,948
Latest member
UsmanAli786

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