DEV Community

Oscar Sun(孫守真字任真)
Oscar Sun(孫守真字任真)

Posted on

Answer: How do I use the replace feature in a VSTO C# add-in with Wildcards?

You have to set the arguments MatchWildcards,Replace in the Execute method and .Find.Replacement.Text = replacementText and don't forget to reset the range wordRange itself :

        public void FindAndReplaceWildcardPlayGround(string wildCardText, string replacementText, string commentMessage)
        {
            Microsoft.Office.Interop.Word.Range wordRange = null
            Word.Document document = this.Application.ActiveDocument;
            wordRange = document.Content;
            wordRange.Find.ClearFormatting();
            wordRange.Find.ClearAllFuzzyOptions();
            wordRange.Find.Replacement.ClearFormatting();

Top comments (0)