更新时间:2023-02-07 23:20:52
这是单词部分的简短循环.获取段落样式的名称,并检查它的名称.该名称将根据您的文档模板中定义的内容而有所不同.
Here's a short loop for the word part. Get the name of the style for a paragraph, and check it's name. The name will differ according to what is defined in your document template.
foreach (Paragraph paragraph in this.Application.ActiveDocument.Paragraphs)
{
Style style = paragraph.get_Style() as Style;
string styleName = style.NameLocal;
string text = paragraph.Range.Text;
if( styleName == "Normal" ) // do something
else if( styleName == "Heading 1" ) // do something
}