smile
smile

Reputation: 105

Get list of styles from Word file

Is there any way to get list of all style names contained in word file? I am using Spire.Doc an I know how get all used styles, but I need all available style names.

List should include these styles

Upvotes: 0

Views: 1929

Answers (1)

Josep B.
Josep B.

Reputation: 587

Check that:

object missing = System.Reflection.Missing.Value;
object fileName = "C:\\test.docx";
Microsoft.Office.Interop.Word.Application applicationWord = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document documentWord = new  Microsoft.Office.Interop.Word.Document();
documentWord = applicationWord.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref  missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
foreach (Microsoft.Office.Interop.Word.Style currentStyle in documentWord.Styles)
{
     string name = currentStyle.NameLocal;
}

Upvotes: 1

Related Questions