Intrope Word

MNH ASP 101 Reputation points

Hello Guys,

I have Word Document. I need to replace word by regex using intrope c# library i don't know how to do it.
Can you please suggest me. or provide code snippet for that....

pattern => ${word}

Thank you :)

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,620 questions
{count} votes

Accepted answer
  1. Jack J Jun 24,491 Reputation points Microsoft Vendor

    @MNH ASP , Welcome to Microsoft Q&A, I suggest that you could use Find.MatchWildcards property (Word) to replace word by using regex in word file.

    Here is a code example you could refer to.

    I changed the words that start with Example to This is Example.

      static void Main(string[] args)  
                Word.Application app=new Word.Application();  
                Word.Document doc = app.Documents.Open("test1.docx");  
                object missing = Missing.Value;  
                Word.Find findObject = app.Selection.Find;  
                findObject.Text = "Example@";  
                findObject.MatchWildcards = true;  
                findObject.Replacement.Text = "This is Example";  
                object replaceAll = Word.WdReplace.wdReplaceAll;  
                findObject.Execute(ref missing, ref missing, ref missing, ref missing, ref missing,  
                    ref missing, ref missing, ref missing, ref missing, ref missing,  
                    ref replaceAll, ref missing, ref missing, ref missing, ref missing);  



    Best Regards,

    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful