使用数组查找.Execute

时间:2015-08-06 14:36:12

标签: c# ms-word

我正在使用Find.Execute在word文档中搜索某些关键字,但在尝试在数组中搜索关键字时似乎存在问题。此外,当尝试重复每个单词的代码时,它们不能一起工作。任何人都可以建议解决这个问题?

        object[] words = { "references", "contents","abstract"};
        int foundpages =0;
        wordApp.Selection.Find.ClearFormatting();
        for (int i = 0; i < words.Length; i++ )
        {
            for (int j = 0; j < TotalNumPages; j++)
            {
                wordApp.Selection.Find.ClearFormatting();
                //Console.WriteLine(words[i]);
                if (wordApp.Selection.Find.Execute(words[i],
                false, ref missing, ref missing, ref missing, true, ref missing,
                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                ref missing, ref missing))
                {
                    foundpages = wordApp.Selection.Range.get_Information(Word.WdInformation.wdActiveEndPageNumber);
                    Console.WriteLine("found word " + words[i] + " at page: " + foundpages);
                }


            }

        }

提前致谢

0 个答案:

没有答案