+ Reply to Thread
Results 1 to 2 of 2

Spell Check in a form

Hybrid View

raw Spell Check in a form 11-26-2006, 06:26 PM
Simon Lloyd This needs to go in the code... 11-27-2006, 11:49 AM
  1. #1
    Registered User
    Join Date
    10-24-2005
    Posts
    55

    Spell Check in a form

    Hi there

    I have a 4 forms that users enter input ie 1st forum name, address, tel No., 2nd forum, price VAT, and then the 3rd form which the user enters the description of the item "1 No. seat cover and bag made at ............. and so on"

    Can you have the spell check tool check the text entered in the forum (the 3rd one) checked before the information is sent to a sheet? Can a button be added to the forum that you click and the spell check starts just like the tool bar one?

    Many thanks

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    This needs to go in the code sheet for the userform
    Private Sub cmdSpellXtra_Click()
    If IsSpellingCorrect(TextBox1.Text) Then
          cmdSpellXtra.BackColor = &HFF00&
        Else
                cmdSpellXtra.BackColor = &HFF&
          strSpellCheckXtra = TextBox1.Text
          ThisWorkbook.Worksheets("SpellCheck").Cells(1, 1).Value = strSpellCheckXtra
          'Now Check spelling
          ThisWorkbook.Worksheets("SpellCheck").Cells(1, 1).CheckSpelling AlwaysSuggest:=True
          TextBox1.Text = ThisWorkbook.Worksheets("SpellCheck").Cells(1, 1).Text
          cmdSpellXtra.BackColor = &HFF00&
        End If
    End Sub
    also this code needs to go in the same module
    Function IsSpellingCorrect(ByVal sInput As String) As Boolean
    
    Dim i As Long
    Dim lLength As Long
    Dim lWordLen As Long
    Dim sTmp As String
    Dim bSpellingOK As Boolean
    Dim vWords As Variant
    Dim sArr() As String
    Dim iCount As Integer
    
    
       If Len(sInput) < 256 Then
         IsSpellingCorrect = Application.CheckSpelling(sInput)
         Exit Function
       End If
       
       vWords = Split(sInput, Chr(32), -1, vbBinaryCompare)
       
       sTmp = ""
       lLength = 0
       iCount = 0
       For i = LBound(vWords) To UBound(vWords)
         lWordLen = Len(vWords(i))
           If lLength + lWordLen < 256 Then
             sTmp = sTmp & vWords(i) & " "
           Else
             iCount = iCount + 1
             ReDim Preserve sArr(1 To iCount)
             sArr(iCount) = sTmp
             sTmp = ""
           End If
           lLength = Len(sTmp)
       Next i
       If lLength > 0 Then
         iCount = iCount + 1
         ReDim Preserve sArr(1 To iCount)
         sArr(iCount) = sTmp
       End If
       For i = 1 To iCount
         bSpellingOK = Application.CheckSpelling(sArr(i))
         If Not bSpellingOK Then Exit For
       Next i
       IsSpellingCorrect = bSpellingOK
       
    End Function
    you might find you have to change the name of the textbox and your command button click, this code also relies on you having a hidden worksheet called "SpellCheck".

    The code isn't mine just one i've adapted from the net!

    Regards,
    Simon

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1