How to get Spell Suggestions from MS-Word in VB

J

jaz

Hi...

I am developing my own spell checker in VB using Ms- Word as Reference.

I want to use custom-Dictionary(Multilangauge) which is available
with MS-word.

I tried to get Spell Suggestions by using function


ObjWord.GetSpellSuggestions (StrTEXT)

I got suggestions for English Language but for Other than Englsih (e.g.
Arabic).. I could not get suggestions for arabic Langauge....
How to Arabic Suggestions from Arabic Dictionary .

Same thing working with MS-Word ....But I need it in VB .


Thanking you
 
G

Guest

Here's the function that I use in my desktop app.
Send me an email if you want the whole thing, but this function is 90%
of the code

(e-mail address removed)


'----------------------------------------------------
' Spell Checking using WORD Automation
' Include Microsoft Word 9.0 Object Library
'----------------------------------------------------
Public Function SpellCheck(ByRef strBuffer As String) As String
Dim objWord As Word.Application
Dim WordDoc As Word.Document
Dim strlen As Integer

On Error GoTo WordAutoError
Set objWord = New Word.Application
Set WordDoc = objWord.Documents.Add
objWord.Visible = False
objWord.WindowState = wdWindowStateMinimize

objWord.Selection.Text = strBuffer 'get text

'gLANGUAGE CHECK?
objWord.Selection.LanguageID = wdEnglishUS 'Set language:
WordDoc.CheckSpelling ' Check spelling:

objWord.Selection.WholeStory ' select text
strBuffer = objWord.Selection.Text
' Text w/o last paragraph mark back to the VB Textbox:

' strip off CR/LF on end of string
strlen = Len(strBuffer)
While (strlen > 0 And ((Right(strBuffer, 1) = vbCr) Or
(Right(strBuffer, 1) = vbLf)))
strlen = strlen - 1
strBuffer = Left(strBuffer, strlen)
Wend
SpellCheck = strBuffer

' -- Close w/o saving:
objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
objWord.Quit
Set objWord = Nothing ' Free
memory:
Exit Function

WordAutoError:
SpellCheck = strBuffer
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top