Click to See Complete Forum and Search --> : HELP... Spell Check from the Web


womalley
September 17th, 2003, 01:02 PM
Ok here is the situation. I have a textbox that suports rich text formatting so a user can write in bold italics.. ect.

When I do the spell check how ever I get one of two unwanted results either the spellcheck box will popup and show the user not only what is spelled wrong but also the HTML tags used for formatting. On the other hand if I change the code a little th HTML tags don't show but I loose the formatting.

Here is the code


Sub RichTextSpellChecker(ItemToCheck)
Dim WordObject
Dim WordDocumentObject
Dim strReturnValue
Dim strValueToCheck
strValueToCheck = "" & document.getElementById(ItemToCheck).innerHTML

IF NOT (strValueToCheck = "") THEN
'let the user know that the spelling is being checked.
window.status = "Spell Check is processing, please wait this may take a few seconds."

'Create a new instance of word Application
Set WordObject = CreateObject("word.Application")
'set window parameters
WordObject.WindowState = 2
WordObject.Visible = False

'Create a new instance of Document and add the text to the document
Set WordDocumentObject = WordObject.Documents.Add( , , 1, True)
'Set WordDocumentObject = WordObject.Documents.Add

WordDocumentObject.Content = strValueToCheck
WordDocumentObject.CheckSpelling

'Return spell check completed text data
strReturnValue = WordDocumentObject.Content
'give the corrected spelling to the textbox that was checked
MsgBox(strReturnValue)
document.getElementById(ItemToCheck).innerHTML = strReturnValue

' House Cleaning
'Close Word Document
WordDocumentObject.Close False
'Set Document To nothing
Set WordDocumentObject = Nothing

'Quit Word
WordObject.Application.Quit True
'Set word object To nothing
Set WordObject= Nothing
'let the user know that the spell check has completed. just incase it takes a few seconds to reload the page.
window.status = "Spell check is complete"
END IF
End Sub




Any help would be great..

Thanks alot
William O'Malley