Hello Everyone:
I am having problem with my code; i ma trying to setup a Spell Check button. when I truy to compile the code I get the following error message when it gets to this line:
strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)
Public Property Left() As Integer' has no parameters and its return type cannot be indexed.
What am i missing? thanks in advance.
'**********************************************
Private Sub BtnSpellCheck1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSpellCheck1.Click
Dim objWord As Object
Dim objDoc As Object
Dim strResult As String
'Create a new instance of word Application
objWord = CreateObject("word.Application")
Select Case objWord.Version
'Office 2000
Case "9.0"
objDoc = objWord.Documents.Add(, , 1, True)
'Office XP
Case "10.0"
objDoc = objWord.Documents.Add(, , 1, True)
'Office 97
Case Else ' Office 97
objDoc = objWord.Documents.Add
End Select
objDoc.Content = RichTextBox1.Text
objDoc.CheckSpelling()
strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)
If RichTextBox1.Text = strResult Then
' There were no spelling errors, so give the user a
' visual signal that something happened
MsgBox("The spelling check is complete.", vbInformation + vbOKOnly)
End If
'Clean up
objDoc.Close(False)
objDoc = Nothing
objWord.Application.Quit(True)
objWord = Nothing
' Replace the selected text with the corrected text. It's important that
' this be done after the "Clean Up" because otherwise there are problems
' with the screen not repainting
RichTextBox1.Text = strResult
Exit Sub
End Sub