I have a document (MS Word) and I applied the "Line (Distincive)" style to it. Now I want to get the name of Style in this document (Line Distincive) with using C#. I don't know how to solve this problem. This is my code.
void ApplyStyleDocument()
{
object w;
Microsoft.Office.Interop.Word.Document _activeDoc;
try
{
w = System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
}
catch (Exception ex)
{
Type type = Type.GetTypeFromProgID("Word.Application");
w = System.Activator.CreateInstance(type);
}
Microsoft.Office.Interop.Word.Application oWord = (Microsoft.Office.Interop.Word.Application)w;
_activeDoc = oWord.ActiveDocument;
MessageBox.Show(_activeDoc.Styles.GetType().Name.ToString());
}
您需要从ParagraphProperties
获取样式,如下所示:
var style = paragraph.ParagraphProperties.ParagraphStyleId.Val.Value;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.