Results 1 to 14 of 14

Thread: Turning on autocorrect on in a TextBox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Turning on autocorrect on in a TextBox

    Does anyone know how to turn autocorrect on in a TextBox in Word?

    caz

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Turning on autocorrect on in a TextBox

    To turn on spelling as you type...


    VB Code:
    1. Options.CheckSpellingAsYouType = True
    But to check spelling in an ActiveX or Forms Textbox you will need to code the spellchecking manually as Word does not check them.

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: Turning on autocorrect on in a TextBox

    Thanks robb, thats not really what i wanted though, Unless it is and my inexperience is showing. i wanted to turn autocorrect on.

    caz

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Turning on autocorrect on in a TextBox

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: Turning on autocorrect on in a 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:
    1. Private db As Database
    2. Private rs As Recordset
    3.  
    4.  
    5. Private Sub Form_Load()
    6.  
    7. Set db = OpenDatabase("C:\Documents and Settings\Matthew\Desktop\TEST.mdb")
    8. Set rs = db.OpenRecordset("tblTEST", dbOpenDynaset)
    9.  
    10. End Sub
    11.  
    12. Private Sub Text1_Change()
    13.  
    14. End Sub
    15.  
    16. Private Sub txtSearchText_KeyUp(KeyAscii As Integer, Shift As Integer)
    17.     Dim Prts() As String
    18.     Dim tmpText As String
    19.    
    20.     If KeyAscii = 32 Or KeyAscii = 46 Then
    21.        
    22.         If txtSearchText.Text <> "" Then
    23.         tmpText = txtSearchText
    24.             Prts = Split(txtSearchText.Text, " ")
    25.             For x = 0 To UBound(Prts)
    26.                 rs.FindFirst "[SearchText] = '" & Prts(x) & "'"
    27.                 If Not rs.NoMatch Then
    28.                     tmpText = Replace(tmpText, Prts(x), rs.Fields("ReplacementText"))
    29.                 End If
    30.             Next
    31.             Text1 = tmpText
    32.         End If
    33.     End If
    34. End Sub
    Last edited by caz1805; May 1st, 2006 at 02:46 PM.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Turning on autocorrect on in a TextBox

    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?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: Turning on autocorrect on in a TextBox

    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

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Turning on autocorrect on in a TextBox

    Oh, ok. So is the code working for you? What version of Access?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: Turning on autocorrect on in a TextBox

    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

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Turning on autocorrect on in a TextBox

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: Turning on autocorrect on in a TextBox

    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

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Turning on autocorrect on in a TextBox

    Post your updates code. If its a straight replace then the textbox keypress event should suffice.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: Turning on autocorrect on in a TextBox

    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:
    1. Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    2.     Dim Prts() As String
    3.     Dim tmpText As String
    4.  
    5.     If KeyAscii = 32 Or KeyAscii = 46 Then
    6.  
    7.         If TextBox2.Text <> "" Then
    8.         tmpText = TextBox2.Text
    9.             Prts = Split(TextBox2.Text, " ")
    10.             For x = 0 To UBound(Prts)
    11.                rs.FindFirst "[SearchText] = '" & Prts(x) & "'"
    12.                 If Not rs.NoMatch Then
    13.                     tmpText = Replace(tmpText, Prts(x), rs.Fields("ReplacementText"))
    14.                 End If
    15.             Next
    16.            TextBox2.Text = tmpText
    17.         End If
    18.     End If
    19. End Sub

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: Turning on autocorrect on in a TextBox

    any help would be great.

    caz

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width