Hi,
I have a VB windows form using VS2005 that calls the MS Word object to spell check a multiline textbox on my form. The spell check works fine, however after the text is returned back to the textbox it combines all the paragraphs together and displays a carriage return character between the paragraphs. I'm not sure why it is doing that. Can anyone reproduce this behavior. And if so, why does it return the text like that?
Here is a before and after sample of what is happening here....
Before...
This is a test paragraph.
This is another test paragraph for spacing.
This is yet another test paragraph for testing the format and spacing after spell check is performed.
After Spell Check.....
This is a test paragraph.**This is another test paragraph for spacing.**This is yet another test paragraph for testing the format and spacing after spell check is performed.
where * equals a character that looks like a box that represents a carriage return.
Here is the routine I am using for spell check....
Thanks,
Razzle
I have a VB windows form using VS2005 that calls the MS Word object to spell check a multiline textbox on my form. The spell check works fine, however after the text is returned back to the textbox it combines all the paragraphs together and displays a carriage return character between the paragraphs. I'm not sure why it is doing that. Can anyone reproduce this behavior. And if so, why does it return the text like that?
Here is a before and after sample of what is happening here....
Before...
This is a test paragraph.
This is another test paragraph for spacing.
This is yet another test paragraph for testing the format and spacing after spell check is performed.
After Spell Check.....
This is a test paragraph.**This is another test paragraph for spacing.**This is yet another test paragraph for testing the format and spacing after spell check is performed.
where * equals a character that looks like a box that represents a carriage return.
Here is the routine I am using for spell check....
Code:
Private Sub SpellCheck()
If txtnotes.Text.Length > 0 Then
' Make a Word server object.
Dim word_server As New Word.Application
' Hide the server.
word_server.Visible = False
' Make a Word Document.
Dim doc As Word.Document = _
word_server.Documents.Add()
Dim rng As Word.Range
' Make a Range to represent the Document.
rng = doc.Range()
' Copy the text into the Document.
rng.Text = txtnotes.Text
' Activate the Document and call its CheckSpelling
' method.
doc.Activate()
doc.CheckSpelling()
' Copy the results back into the TextBox,
' trimming off trailing CR and LF characters.
Dim chars() As Char = {CType(vbCr, Char), CType(vbLf, Char)}
txtnotes.Text = doc.Range().Text.Trim(chars)
' Close the Document, not saving changes.
doc.Close(SaveChanges:=False)
' Close the Word server.
word_server.Quit()
End If
End Sub
Thanks,
Razzle