我在我的应用中使用Microsoft Word来使用拼写检查对话框。每当您使用拼写检查时,Office都会打开。有没有办法阻止它?
这是我的代码:
Word.Application app = new Word.Application();
int errors = 0;
if (richTextBox1.Text.Length > 0) {
app.Visible = false;
this.BringToFront();
// 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;
Word._Document doc1 = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);
doc1.Words.First.InsertBefore(richTextBox1.Text);
Word.ProofreadingErrors spellErrorsColl = doc1.SpellingErrors;
errors = spellErrorsColl.Count;
object optional = Missing.Value;
doc1.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);
object first = 0;
object last = doc1.Characters.Count - 1;
richTextBox1.Text = doc1.Range(ref first, ref last).Text;
}
object saveChanges = false;
object originalFormat = Missing.Value;
object routeDocument = Missing.Value;
app.Quit(ref saveChanges, ref originalFormat, ref routeDocument);