G
Guest
Hello,
I am passing a string to a spell checking function which performs spell
check using word objects. It works fine but even though i have said
oWord.Visible = false;
the word application opens for a moment and closes ,which makes my winform
application look bad. Is there any way to supress that.
The C# function i wrote is below.
private String SpellCheck(String str)
{
try
{
object oMissing = System.Reflection.Missing.Value;
String retVal = "";
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = false;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
ref oMissing, ref oMissing);
oDoc.Content.Text = str;
oDoc.CheckGrammar();
oDoc.Content.Copy();
retVal =
Clipboard.GetDataObject().GetData(DataFormats.Text).ToString();
oDoc.Saved = true;
oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
return retVal;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " : " + ex.Source + " : " +
ex.StackTrace);
return "Fatal Error";
}
}
I am passing a string to a spell checking function which performs spell
check using word objects. It works fine but even though i have said
oWord.Visible = false;
the word application opens for a moment and closes ,which makes my winform
application look bad. Is there any way to supress that.
The C# function i wrote is below.
private String SpellCheck(String str)
{
try
{
object oMissing = System.Reflection.Missing.Value;
String retVal = "";
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = false;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
ref oMissing, ref oMissing);
oDoc.Content.Text = str;
oDoc.CheckGrammar();
oDoc.Content.Copy();
retVal =
Clipboard.GetDataObject().GetData(DataFormats.Text).ToString();
oDoc.Saved = true;
oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
return retVal;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " : " + ex.Source + " : " +
ex.StackTrace);
return "Fatal Error";
}
}