C#-从MS word 2007中搜索和删除特定行
我正在使用C#的WORD 2007。 我有一个MS word 2007文档和一个带有特定字符串的列表strList。 现在我需要逐行“运行”word文档并删除列表strList中不存在的所有行。 任何帮助都会很好。C#-从MS word 2007中搜索和删除特定行,c#,ms-word,C#,Ms Word,我正在使用C#的WORD 2007。 我有一个MS word 2007文档和一个带有特定字符串的列表strList。 现在我需要逐行“运行”word文档并删除列表strList中不存在的所有行。 任何帮助都会很好。 谢谢 考虑到你会付出更多的努力,这里有一些东西应该对你有所帮助。此示例显示循环遍历Word集合并读取每个元素的Text属性。然后显示文本内容。最后在应用程序实例上调用Quit using System; using Microsoft.Office.Interop.Word; cl
谢谢 考虑到你会付出更多的努力,这里有一些东西应该对你有所帮助。此示例显示循环遍历Word集合并读取每个元素的Text属性。然后显示文本内容。最后在应用程序实例上调用Quit
using System;
using Microsoft.Office.Interop.Word;
class Program
{
static void Main()
{
// Open a doc file.
Application application = new Application();
Document document = application.Documents.Open("C:\\word.doc");
// Loop through all words in the document.
int count = document.Words.Count;
for (int i = 1; i <= count; i++)
{
// Write the word.
string text = document.Words[i].Text;
Console.WriteLine("Word {0} = {1}", i, text);
}
// Close word.
application.Quit();
}
}
使用系统;
使用Microsoft.Office.Interop.Word;
班级计划
{
静态void Main()
{
//打开一个文档文件。
应用程序=新应用程序();
Document Document=application.Documents.Open(“C:\\word.doc”);
//循环浏览文档中的所有单词。
int count=document.Words.count;
对于(inti=1;我可以请您添加一些源代码吗?