Does anyone know how to turn autocorrect on in a TextBox in Word?
caz
Printable View
Does anyone know how to turn autocorrect on in a TextBox in Word?
caz
To turn on spelling as you type...
But to check spelling in an ActiveX or Forms Textbox you will need to code the spellchecking manually as Word does not check them.VB Code:
Options.CheckSpellingAsYouType = True
Check out the code example in my signature "VB/Office Guru Advanced SpellCheckerâ„¢ for VB6" as it shows the technique you will need to do.
Thanks robb, thats not really what i wanted though, Unless it is and my inexperience is showing. i wanted to turn autocorrect on.
caz
Well I was getting at the fact that you can not autocorrect text as you type in anything other then the document and not in any ActiveX controls like a textbox. You would have to pass the textbox contents to some custom function that looks it up in a dictionry and then replace it.
There is another possibility, download the smart tag sdk from ms and create your own smart tag for duplicating the autocorrect but in the textbox.
Okay thanks robb. I am going to try and use the find/replace function. I have created a program in VB6 which translated the words from an access database.
I am going to see if i can convert it to VBA code any help would be much appreciated.
caz
VB Code:
Private db As Database Private rs As Recordset Private Sub Form_Load() Set db = OpenDatabase("C:\Documents and Settings\Matthew\Desktop\TEST.mdb") Set rs = db.OpenRecordset("tblTEST", dbOpenDynaset) End Sub Private Sub Text1_Change() End Sub Private Sub txtSearchText_KeyUp(KeyAscii As Integer, Shift As Integer) Dim Prts() As String Dim tmpText As String If KeyAscii = 32 Or KeyAscii = 46 Then If txtSearchText.Text <> "" Then tmpText = txtSearchText Prts = Split(txtSearchText.Text, " ") For x = 0 To UBound(Prts) rs.FindFirst "[SearchText] = '" & Prts(x) & "'" If Not rs.NoMatch Then tmpText = Replace(tmpText, Prts(x), rs.Fields("ReplacementText")) End If Next Text1 = tmpText End If End If End Sub
Find and Replace do not search in an ActiveX textbox control. It will only work in the contents of a document. You will have to iterate through the textboxes on your document and code the find/replace.
Why are you using a db for the replaced text?
I was using a database as I had a large amount of words to be replaced and that program completed it on the 'fly' like autocorrect. Thats why i was looking into autocorrect as a possible and easier solution but to no avail.
caz
Oh, ok. So is the code working for you? What version of Access?
Yeh the code works in VB6 with Word and Access 2002.
With your expertise and excvellent knowledge do you believe i could do this in WOrd?
caz
Sure, looks like your using DAO so in the VBA IDE add a reference to DAO 3.6 and add your code. There is no Form_Load but change it to Document_Open.
thanks alot robb
I am getting stumped because the VB6 program was all based on textboxes and u said i could not do this in VBA. So how would i recreate this with the ActiveDocument. Or even so that i type it into the ActiveDocument and it is replaced into the TextBox?
i am going to try soi will let u know if i figure out how to do it,
]
caz
Post your updates code. If its a straight replace then the textbox keypress event should suffice.
Hi guys me again, I have managed to create the form and get nearly everything working except that the keyup does not seem to be firing. So it is going along without the replacement text being sent to textbox1 from textbox2.
All the files are being referenced to and everything its something to do with the keyup and keyspace button but i just cant figure it out.
thanks for any help.
caz
p.s. Robbdog do u never sleep!!!
VB Code:
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Dim Prts() As String Dim tmpText As String If KeyAscii = 32 Or KeyAscii = 46 Then If TextBox2.Text <> "" Then tmpText = TextBox2.Text Prts = Split(TextBox2.Text, " ") For x = 0 To UBound(Prts) rs.FindFirst "[SearchText] = '" & Prts(x) & "'" If Not rs.NoMatch Then tmpText = Replace(tmpText, Prts(x), rs.Fields("ReplacementText")) End If Next TextBox2.Text = tmpText End If End If End Sub
any help would be great.
caz