Advertisement
ASP_Volume3 Miscellaneous #45260

A Better SpellChecker

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

AI

AI 摘要: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

源代码
original-source
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

<button onclick="window.opener=null;window.close()">CLOSE THE WINDOW</button>
原始评论 (3)
从 Wayback Machine 恢复