swap

swap

  • NA
  • 1
  • 0

Language setting in spell check

Jun 16 2006 5:07 AM
 i am using following function for spell check

but  i want to give language selection option (ex. ComboBox with options such as EnglishUS,EnglishUK,Spanish etc) in my form

So please tell me how to set Language selection option in my code.

Is it possible using Languade ID ?

Please solve my problem as soon as possible....

 

public

void fSpellCheck(TextBox tBox, Label lLbl)

{

int iErrorCount = 0;

Word.

Application app = new Word.Application();

if (tBox.Text.Length > 0)

{

app.Visible=

false;

// Setting these variables is comparable to passing null to the function.

// This is necessary because the C# null cannot be passed by reference.

object template=Missing.Value;

object newTemplate=Missing.Value;

object documentType=Missing.Value;

object visible=true;

object optional = Missing.Value;

//string sss=app.HangulHanjaDictionaries.ActiveCustomDictionary.Name;

_Document doc = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);
 
//i think here we can set language for doc object of Ms-word but i don't know how?
//doc.language or somthing

doc.Words.First.InsertBefore (tBox.Text );

Word.

ProofreadingErrors we = doc.SpellingErrors;

iErrorCount = we.Count;

doc.CheckSpelling(

ref optional, ref optional, ref optional, ref optional,

ref optional, ref optional, ref optional,

ref optional, ref optional, ref optional, ref optional, ref optional);

if (iErrorCount == 0)

lLbl.Text =

"Spelling OK. No errors corrected ";

else if (iErrorCount == 1)

lLbl.Text =

"Spelling OK. 1 error corrected ";

else

lLbl.Text =

"Spelling OK. " + iErrorCount + " errors corrected ";

object first=0;

object last=doc.Characters.Count -1;

tBox.Text = doc.Range(

ref first, ref last).Text;

}

else

lLbl.Text =

"Textbox is empty";

object saveChanges = false;

object originalFormat = Missing.Value;

object routeDocument = Missing.Value;

app.Quit(

ref saveChanges, ref originalFormat, ref routeDocument);

}