Results 1 to 4 of 4

Thread: Spell Check a TextBox

  1. #1

    Thread Starter
    Member ThePCMan's Avatar
    Join Date
    Dec 2004
    Location
    Aylesbury, UK
    Posts
    33

    Spell Check a TextBox

    VB Code:
    1. Add this code to a command button or popup menu item.
    2. visual basic code:
    3.    
    4.     Dim objWord As Object
    5.     Dim objDoc  As Object
    6.     Dim strResult As String
    7.    
    8.     'Create a new instance of word Application
    9.     Set objWord = CreateObject("word.Application")
    10.  
    11.     Select Case objWord.Version
    12.         'Office 2000
    13.         Case "9.0"
    14.             Set objDoc = objWord.Documents.Add(, , 1, True)
    15.         'Office XP
    16.         Case "10.0"
    17.             Set objDoc = objWord.Documents.Add(, , 1, True)
    18.         'Office 97
    19.         Case Else ' Office 97
    20.             Set objDoc = objWord.Documents.Add
    21.     End Select
    22.  
    23.     objDoc.Content = Text1.Text
    24.     objDoc.CheckSpelling
    25.  
    26.     strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)
    27.  
    28.     If Text1.Text = strResult Then
    29.         ' There were no spelling errors, so give the user a
    30.         ' visual signal that something happened
    31.         MsgBox "The spelling check is complete.", vbInformation + vbOKOnly
    32.     End If
    33.    
    34.     'Clean up
    35.     objDoc.Close False
    36.     Set objDoc = Nothing
    37.     objWord.Application.Quit True
    38.     Set objWord = Nothing
    39.  
    40.     ' Replace the selected text with the corrected text. It's important that
    41.     ' this be done after the "Clean Up" because otherwise there are problems
    42.     ' with the screen not repainting
    43.     Text1.Text = strResult
    44.  
    45.     Exit Sub

    How do u get it 2 check mulitple textboxes?? Do u enter the names here:

    VB Code:
    1. objDoc.Content = [COLOR=DarkRed]Text1.Text[/COLOR]
    2.     objDoc.CheckSpelling
    3.  
    4.     strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)
    5.  
    6.     If [COLOR=DarkRed]Text1.Text [/COLOR] = strResult Then
    7.         ' There were no spelling errors, so give the user a
    8.         ' visual signal that something happened
    9.         MsgBox "The spelling check is complete.", vbInformation + vbOKOnly
    10.     End If
    11.     And finally [COLOR=DarkRed]Text1.Text [/COLOR] = strResult

  2. #2

    Re: Spell Check a TextBox

    objDoc.Content = Text1.Text
    objDoc.CheckSpelling

    strResult1 = Left(objDoc.Content, Len(objDoc.Content) - 1)

    objDoc.Content = Text2.Text
    objDoc.CheckSpelling

    strResult2 = Left(objDoc.Content, Len(objDoc.Content) - 1)

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Spell Check a TextBox

    ThePCMan. I just want to point out that you should read the sticky at the top of this forum. If you do you'll find the following suggestion:

    In order to avoid duplicating something that is already in the Codebank, please do a search before posting.
    In your case you might have found that you've copied my code.

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