Public Class SpellChecker
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
Public Sub New()
MyBase.New()
'This call is required by the Web Services Designer.
InitializeComponent()
'Add your own initialization code after the InitializeComponent() call
End Sub
'Required by the Web Services Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Web Services Designer
'It can be modified using the Web Services Designer.
'Do not modify it using the code editor.
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'CODEGEN: This procedure is required by the Web Services Designer
'Do not modify it using the code editor.
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#End Region
<WebMethod()> Public Function CheckSpelling(ByVal inString As String) As String
Dim bResult As Boolean
Dim strReturn As String
Dim filler As Object
Try
Dim objWord As New Word.Application()
Dim tmpDoc As Word.Document
Dim arySuggestions As Word.SpellingSuggestions
Dim Suggestion As Word.SpellingSuggestion
tmpDoc = objWord.Documents.Add 'creates a blank document for holding values
bResult = objWord.CheckSpelling(inString, filler, filler, _
filler, filler, filler, filler, filler, filler, filler, filler, filler, filler)
If Not bResult Then
arySuggestions = objWord.GetSpellingSuggestions(inString)
For Each Suggestion In arySuggestions
strReturn = strReturn & Suggestion.Name & ", "
Next
arySuggestions = Nothing
Suggestion = Nothing
End If
strReturn = "Spell check result: " & bResult & " Suggested words: " & strReturn
tmpDoc.Saved = True
objWord = Nothing
tmpDoc = Nothing
Catch ex As Exception
strReturn = ex.Message
End Try
Return strReturn
End Function
End Class