2
有人可能指向我在正确的方向,或告诉我如何找到使用c#.net中的词互操作的他们的风格名称的段落。按照风格在词2010查找段落使用interop
有人可能指向我在正确的方向,或告诉我如何找到使用c#.net中的词互操作的他们的风格名称的段落。按照风格在词2010查找段落使用interop
尝试循环是这样的:
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);
}
}
这个问题好像是问类似的东西: http://stackoverflow.com/questions/865340/vsto-2007-how-do-i-determine-the -page和 - 段落数对的一范围 – 2013-05-08 14:35:56