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

Free Support Forum - aspose.com

Aspose word bookmark apply style

Please help on how to apply style on already created bookmark?

the word template already has bookmarks…through aspose find the bookmark and apply text and style to it.

Please advise.

Hi there,

Thanks for your inquiry. Please use ParagraphFormat.Style property to get or set the paragraph style applied to paragraph. Following code example shows how to set style of paragraphs of a bookmark.

If you face any issue, please share your input and expected output documents here for our reference. We will then provide you more information about your query.

Document doc = new Document(MyDir + "in.docx");
Bookmark bm = doc.Range.Bookmarks["bm"];
Node node = bm.BookmarkStart;
node = node.ParentNode;
while (bm.BookmarkEnd != node)
    if (node.NodeType == NodeType.Paragraph)
        Paragraph para = (Paragraph)node;
        foreach (Run run in para.Runs)
        // set the paragraph style 
        para.ParagraphFormat.StyleName = "Heading 1";
    node = node.NextPreOrder(doc);
doc.Save(MyDir + "17.4.docx");