HTML formattign with Range replace

I have a word doc as a template and I’m currently using range.Replace to replace TOKEN values with data values. The only issue I’m facing is trying to insert Html formatted data using the same method with no success. Is there a work around. Was thinking maybe if there is a way to retrieve the location of the “token” then using the document builder maybe. Any ideas?
thanks,
v.

Hi Voss,

Thanks for your inquiry. Please refer to the following article:
Find and Replace

Following code example shows how to find a text and replace it with HTML. Hope this helps you.

public void ReplaceWithInsertHtml()
{
    // Open the document.
    Document doc = new Document(MyDir + "Range.ReplaceWithInsertHtml.doc");
    doc.Range.Replace(new Regex(@""), "", new FindReplaceOptions { ReplacingCallback = new ReplaceWithHtmlEvaluator() });
    // Save the modified document.
    doc.Save(MyDir + "Range.ReplaceWithInsertHtml Out.doc");
}
private class ReplaceWithHtmlEvaluator : IReplacingCallback
{
    /// 
    /// NOTE: This is a simplistic method that will only work well when the match
    /// starts at the beginning of a run.
    /// 
    ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
    {
        DocumentBuilder builder = new DocumentBuilder((Document)e.MatchNode.Document);
        builder.MoveTo(e.MatchNode);
        // Replace '' text with html
        builder.InsertHtml("**Aspose.Words**");
        e.Replacement = "";
        return ReplaceAction.Replace;
    }
}

thanks for the reply. A few questions.
I do not seem to have the namespace available Aspose.Words.Replacing (which is what FindReplaceOptions seems to need)
https://reference.aspose.com/words/net/aspose.words.replacing/findreplaceoptions/
I have runtime version v4.0.30319.
Version 16.2.0.0
thanks,
v.

Hi Voss,

Thanks for your inquiry. Please upgrade to the latest version of Aspose.Words for .NET 17.4.

The ReplaceAction, IReplacingCallback and ReplacingArgs had been moved to Aspose.Words.Replacing namespace. We introduced FindReplaceOptions class in Aspose.Words 16.7. Please refer to the release notes:
Aspose.Words for .NET 16.7 Release Notes

Please let us know if you have any more queries.