Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.


Ouput:
Quote:
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);
Posted
Updated 18-Aug-19 21:58pm

1 solution

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


Quote:
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900