We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Format Styles in Word before converting to HTML file

Using Aspose.word, how to find all the Header styles in the document and replace it with custom style via source code. Would like to loop through the style formats in the document and assign a custom style for each header style. like
if header style is “Heading1” , apply
font: Arial, Size :26 ,color: Navy
if header style is “Heading 2” apply a different font, size, color.
How do we achieve it using aspose.word.
application is in vb.net

Hi Ashley,

Thanks for your inquiry. Style Class represents a single built-in or user-defined style. Document.Styles property returns a collection of styles defined in the document.

Following code example shows how to change the font formatting of Heading 1 and Heading 2 styles in a document. Please let us know if you have any more queries.

Dim doc As New Document(MyDir & "in.docx")
For Each style As Style In doc.Styles
If style.Name.Equals("Heading 1") Then
style.Font.Size = 20
style.Font.Name = "Arial"
style.Font.Color = Color.Navy
ElseIf style.Name.Equals("Heading 2") Then
style.Font.Size = 15
style.Font.Name = "Verdana"
style.Font.Color = Color.Lime
End If
doc.Save(MyDir & "Out.docx")