Replace specific words style in existing document

Hi

I want to make specific words bold in an existing document. Can this be achieved in some way? I am using C#. Thanks

Hi,

Try this:

var document = DocumentModel.Load("input.docx");

string searchText = "sample text";
foreach (var content in document.Content.Find(searchText))
{
    var format = ((Run)content.Start.Parent).CharacterFormat.Clone();
    format.Bold = true;
    content.LoadText(searchText, format);
}

document.Save("output.docx");

Also, please check the Find and Replace example.

I hope this helps.

Regards,
Mario