VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A Better SpellChecker

by Cierra Computers & Consulting (5 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This is basically an enhanced version of the SpellCheck function that I found in MSDN from Microsoft. They left out a couple things.

Inputs
Text
Assumes
Be sure to Reference the MS Word Object Library
Code Returns
Text

Rate A Better SpellChecker

Public Function SpellCheck(strText As String, Optional blnSupressMsg As Boolean = False) As String
'This function opens the MS Word Object and uses its spell checker
'passing back the corrected string
On Error Resume Next
Dim oWDBasic As Object
Dim sTmpString As String
If strText = "" Then
   If blnSupressMsg = False Then
     MsgBox "Nothing to spell check.", vbInformation, App.ProductName
   End If
   Exit Function
End If
Screen.MousePointer = vbHourglass
Set oWDBasic = CreateObject("Word.Basic")
With oWDBasic
   .FileNew
   .Insert strText
   .ToolsSpelling oWDBasic.EditSelectAll
   .SetDocumentVar "MyVar", oWDBasic.Selection
End With
sTmpString = oWDBasic.GetDocumentVar("MyVar")
sTmpString = Left(sTmpString, Len(sTmpString) - 1)
If sTmpString = "" Then
   SpellCheck = strText
Else
   SpellCheck = sTmpString
End If
oWDBasic.FileCloseAll 2
oWDBasic.AppClose
Set oWDBasic = Nothing
Screen.MousePointer = vbNormal
If blnSupressMsg = False Then
   MsgBox "Spell check is completed.", vbInformation, App.ProductName
End If
End Function

Download this snippet    Add to My Saved Code

A Better SpellChecker Comments

No comments have been posted about A Better SpellChecker. Why not be the first to post a comment about A Better SpellChecker.

Post your comment

Subject:
Message:
0/1000 characters