Hey guys
EDIT: I get this when I press change spelling "Public member 'Length' on type 'Range' not found"
What should I put instead?
this is the code its in
strResult = objDoc.Content.Substring(0, objDoc.Content.Length - 1)
Im using this code.
Code:
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
'Microsoft Office Word 2007
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.CheckGrammer()
strResult = objDoc.Content.Substring(0, objDoc.Content.Length - 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
Exit Sub
End Sub