Click here to Skip to main content
14,392,000 members
Rate this:
Please Sign up or sign in to vote.
I need to tag string in bold, Underlined, Italics.
Example :
Input : This strings are not in bold but this string are in bold.This is italics.

This strings are [u]not in bold[/u] but [b]this string are in bold[/b].[i]This is italics[/i]

individual words are getting tagged instead of sentence like this [b] Home [/b] [b] Page [/b]/[b] Dashboard [/b] but expected is like [b] Home Page /Dashboard [/b]

What I have tried:

Microsoft.Office.Interop.Word.Range rngFindBold = doc.Content;
           rngFindBold.Find.Font.Bold = -1; //true

rngFindBold.Find.Execute(FindText: "(<*>)", Format: true, ReplaceWith: " ^& ",Wrap:Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue, MatchWildcards: true, Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
Updated 18-Aug-19 22:58pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Based on that piece of code you've provided i can not tell you what's wrong with it, but...

It is important to note that the Find criteria are cumulative, which means that criteria are added to previous search criteria. Clear formatting from previous searches by using the ClearFormatting[^] method prior to the search.

So, you probably need to call ClearFormatting method, before you calss Find.Execute[^] method.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100