使用互操作在word 2010中按样式查找段落
本文关键字:样式 查找 段落 2010 互操作 word | 更新日期: 2023-09-27 18:12:54
有人能指出我在正确的方向,或告诉我如何找到段落的样式名称使用word互操作在c#.net
尝试像这样循环:
using WN = Microsoft.Office.Interop.Word;
//...
WN::Application WordApp;
WordApp = new WN.Application();
//...
WN.Document WordDoc = WordApp.Documents.Open(Filename); //open document
List<string> SelectedParagraphs = new List<string>();
for(int i=1;i<WordDoc.Paragraphs.Count;i++) //numeration of paragraphs starts from 1
{
string WordP = WordDoc.Paragraphs[i].Range.Text; // get paragraph text
string WordS = ((WN.Style)WordDoc.Paragraphs[i].get_Style()).NameLocal; //get paragraph style name
if (WordS=="Needed style")
{
SelectedParagraphs.Add(WordP);
}
}