I tried it out and it does check in multiple languages. Ex: I typed Achtung by default it shows it as an incorrect spelling since the default language is English. If I select the word and right click , select the language as German it recognizes it as valid.
I don't know how to leverage this programatically. How do you tell word which language it should do the spelling and grammar check in?
3 When users try to use other applications while the spellchecker is in progress the screen gets confused and appears to crash.
Do you have a fix for this Martin?
Pretty annoying for the user because if they switch to another application and switch back it's frozen and they have to ctrl/alt/delete to end the application task.
objDoc.CheckSpelling
strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)
' Correct the carriage returns
strResult = Replace(strResult, Chr(13), Chr(13) & Chr(10))
If Text1.Text = strResult Then
' There were no spelling errors, so give the user a
' visual signal that something happened
MsgBox "The spelling check is complete.", vbInformation + vbOKOnly
End If
' There were no spelling errors, so give the user a
' visual signal that something happened
MsgBox "The spell check is complete!", vbInformation + vbOKOnly, "Spelling Complete"
End If
'Clean up
objDoc.Close False
Set objDoc = Nothing
objWord.Application.Quit True
Set objWord = Nothing
' Replace the selected text with the corrected text. It's important that
' this be done after the "Clean Up" because otherwise there are problems
' with the screen not repainting
t.text = strResult
Exit Function
'in case user does not have word...
Err_Handler:
MsgBox Err.Description & Chr(13) & Chr(13) & "Please note you must have Microsoft Word installed to utilize the spell check feature.", vbCritical, "Error #: " & Err.Number
beating my head against my desk in Indianapolis, IN
Posts
58
Re: VB - Spell Check a Textbox
Alright, I'm using this code to check the spelling on a text box when it loses focus. The problem is that if I you want the "mispelled" word to remain and you choose "ignore", I get:
Runtime Error '5' Invalid procedure call or argument
If you are running it from the editor (testing) you don't get this error...if you make an executable you get the error.
Please help.
"The greatest mistake you can make in life is to be continually fearing you will make one."
-Elbert Hubbard
Custom Colors on Disabled Controls
This code is wonderful and will meet my needs if I can get it to work. Using Word and Access 2003. The code runs well until the last line:
Comments.Text = strResult
where Comments is the name of the text box.
The message I get is:
Run-Time error '2115'
The macro or function set to the BeforeUpdate or Validation Rule property for this field is preventing the database from saving the data in the field.
There isn't any code associated with the BeforeUpdate or Validation Rule properties for the field.
OK, I kept trying and decided to use the code for a Function and change the OnKeyDown event for F7. When done this way, the error above is gone but when the text box is checked and corrected, Spell Check continues to the first record of the database and the first textbox on the form.
Just stepped through the code and it all runs. When it finishes, it seems that the regular spell check associated with F7 runs. How can I stop this from happening?
It seems I am almost there.
Thanks
Last edited by hdtvluvr; Nov 20th, 2005 at 04:27 PM.
Thanks for the link. I copied the code and put it in a new module. I couldn't get it to even compile. It doesn't like
Public moApp As Word.Application
or
Set oDoc = moApp.Documents.Add(, , 1, True)
Sorry, but I couldn't even come close to running it since I don't have a dll and a bunch of ocx's it's looking for. If you can tell me which form(s) have the spell checking I'll try to see if I can find anything wrong. Another way we could go about it would be if you could create a plain-vanilla app that has the problem.
beating my head against my desk in Indianapolis, IN
Posts
58
Re: VB - Spell Check a Textbox
Sorry for the long delay on posting a message back. The form that contains the problem is frmReview (the Description field is where I'm testing). The spell checker code is in modSpelling.
I tried to make a plain-vanilla app that had the same problem and guess what...I can't. A similiar program with the same general idea will run spell check without a problem.
"The greatest mistake you can make in life is to be continually fearing you will make one."
-Elbert Hubbard
Custom Colors on Disabled Controls
' There were no spelling errors, so give the user a visual signal that something happened
MsgBox "The spelling check is complete.", vbInformation + vbOKOnly, "Spelling Complete"
End If
'Clean up
objDoc.Close False
Set objDoc = Nothing
objWord.Application.Quit True
Set objWord = Nothing
' Replace the selected text with the corrected text. It's important that
' this be done after the "Clean Up" because otherwise there are problems
' with the screen not repainting
t.Text = strResult
End If
Done:
Exit Sub
'in case user does not have word...
Err_Handler:
MsgBox Err.Description & Chr(13) & Chr(13) & "Please note you must have Microsoft Word installed to utilize the spell check feature.", vbCritical, "Error #: " & Err.Number
beating my head against my desk in Indianapolis, IN
Posts
58
Re: VB - Spell Check a Textbox
I'm a genius!!!!
I figured out the problem I was encountering. I moved the clean up of the object to before the message box informing the user that the check was complete. This seems to have corrected the problem of the Run-time error. I guess it was loosing reference to the word document object.
GO ME!
"The greatest mistake you can make in life is to be continually fearing you will make one."
-Elbert Hubbard
Custom Colors on Disabled Controls
I write a newsletter using vb. The spell check code you have provided is outstanding. I am encounting a problem though. I often have html code (for tables) embedded in my text. When I use this spell check code, it finds a lot of duplicate or repeating 'words' that are just repeating html code. One set in particular is picked up a lot: "0px 0px 0px 0px". The winword code assumes the 0px is repeated and an error. It asks me to "Ignore" or "Delete". There can be 100's of these in my code. Is there any way to tell winword or code that these repeating 'words' are not to be checked?
I write a newsletter using vb. The spell check code you have provided is outstanding. I am encounting a problem though. I often have html code (for tables) embedded in my text. When I use this spell check code, it finds a lot of duplicate or repeating 'words' that are just repeating html code. One set in particular is picked up a lot: "0px 0px 0px 0px". The winword code assumes the 0px is repeated and an error. It asks me to "Ignore" or "Delete". There can be 100's of these in my code. Is there any way to tell winword or code that these repeating 'words' are not to be checked?
Thanks in advance!
I don't currently have time to look into that but the code is there for you to do what you want with, so you can give it a try if you want to.
I write a newsletter using vb. The spell check code you have provided is outstanding. I am encounting a problem though. I often have html code (for tables) embedded in my text. When I use this spell check code, it finds a lot of duplicate or repeating 'words' that are just repeating html code. One set in particular is picked up a lot: "0px 0px 0px 0px". The winword code assumes the 0px is repeated and an error. It asks me to "Ignore" or "Delete". There can be 100's of these in my code. Is there any way to tell winword or code that these repeating 'words' are not to be checked?
Thanks in advance!
You can add the html code that is giving you issues to a custom dictionary or just add it to the default dictionary.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
May I know what is the different between objWord.Documents.Add(, , 1, True) and Set objDoc = objWord.Documents.Add for different version of objWord.Documents?