How to format the text of Word document using .NET

Hi Support,

Is there any way to strikethrough and convert to bold in Aerial font of size 12 for the text present in the bookmark.

I have to do other font size changes to the text present in the bookmark.

Please help,

ValuePRO

Hi Piers,

Thanks for your query. Please use the following code snippet for your requirement. Please let us know if you have any more queries.

Document  doc = new Document(MyDir + “in.docx”);

//Get next node after bookmark start

Node currentNode = doc.Range.Bookmarks["bm"].BookmarkStart.NextSibling;

//Change font of each run inside bookmark

while (currentNode.NodeType != NodeType.BookmarkEnd)

{

if (currentNode.NodeType == NodeType.Run)

{

(currentNode as Run).Font.StrikeThrough = true;

(currentNode as Run).Font.Name = "Arial";

(currentNode as Run).Font.Size = 14;

}

//Move to next node

currentNode = currentNode.NextSibling;

}


doc.Save(MyDir + "AsposeOut.docx");