Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#word拼写检查对话框,如何不打开word_C# - Fatal编程技术网

C#word拼写检查对话框,如何不打开word

C#word拼写检查对话框,如何不打开word,c#,C#,我在c#中使用一个单词引用,我需要知道如何使它在使用拼写检查对话框时不会打开office,下面是代码 private void metroButton8_Click(object sender, EventArgs e) { Word.Application app = new Word.Application(); int errors = 0; if (richTextBox1.Text.Length > 0) { app.Visibl

我在c#中使用一个单词引用,我需要知道如何使它在使用拼写检查对话框时不会打开office,下面是代码

private void metroButton8_Click(object sender, EventArgs e)
{
    Word.Application app = new Word.Application();

    int errors = 0;
    if (richTextBox1.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;

        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;
    }
}
如果您知道如何提供帮助,请执行

在“如果文档或范围包含错误,此方法将显示拼写和语法对话框”中明确指出。因此,请改用app.CheckSpelling()。它在“如果文档或区域包含错误,此方法将显示拼写和语法对话框”中有明确说明。因此,请改用app.CheckSpelling()。