Public Function SpellCheck(ByVal cText As System.String) Dim WordApp As New Word.Application ' object reference for MS Word Dim rngRange As Word.Range ' need range object for spell checking Dim aWordList As New ArrayList ' array list of misspelled words WordApp.Documents.Add() ' add a document and insert the text to be spell-checked rngRange = WordApp.ActiveDocument.Range rngRange.InsertAfter(cText) Dim SpellCollection As Word.ProofreadingErrors ' MS Word proofreading collection SpellCollection = rngRange.SpellingErrors If SpellCollection.Count > 0 Then Dim iword As Integer For iword = 1 To SpellCollection.Count ' populate the arraylist with the words that MS word reported aWordList.Add(SpellCollection.Item(iword).Text) Next End If WordApp.Quit(False) ' close WORD Return aWordList ' bring back the arraylist End FunctionI also have a function that allows users to add words to their Word custom dictionary...
Public Function AddWordToSpellCheck(ByVal cNewWord As System.String) ' when words are 'added' to the MS word dictionary, they actually go to the custom dictionary ' it's normally in the C:\Documents and Settings\Kevin\Application Data\Microsoft\Proof folder, as CUSTOM.DIC ' it's nothing more than a text file, so we just need to open and insert a line with the new word ' I thought there would be a separate function in Word Automation to add a word to a custom dictionary, ' but never found one. Someone on another forum suggested that since the custom dictionary is just a text file, ' to just open it up and add the word ' The contents should probably be re-sorted after the insertion takes place.... Dim WordApp As New Word.Application Dim oDictionary As Word.Dictionary Dim cstring As System.String For Each oDictionary In WordApp.CustomDictionaries ' should only be just one cstring = oDictionary.Path + "\" + oDictionary.Name ' get the location of the custom dictionary ,and the name of it Next Dim w As StreamWriter = File.AppendText(cstring) ' open a streamwriter, add the word, then close the stream w.WriteLine(cNewWord) w.Flush() w.Close() WordApp.Quit(False) End FunctionIf you need anything else, try some searches on MSDN, as there are several examples of this up there. Hope this helps...