本文介绍了MSWord查找和替换方法更改格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach (Microsoft.Office.Interop.Word.Range rng in doc.StoryRanges)
{
    bool hasFound = false;
    rng.Find.Replacement.ClearFormatting();
    rng.Find.Text = findWhat;
    rng.Find.Replacement.Text = replaceText;
    rng.Find.Forward = true;
    rng.Find.MatchCase = false;
    rng.Find.Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindStop;
    rng.Find.Format = true;
    hasFound = rng.Find.Execute(Replace:  
    Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
}



当我执行功能时,它会更改文本的格式,原始文本带有下划线,但使文本变得平淡.有任何想法吗?谢谢

我的状态不一样;原始字串-> ^ t cookie ,我想在Tabs上标后做第一个字母,所以我替换了^ tc-> ^ tC
当我这样做时,最终文本将变成^ tC ookie .我该如何解决?



When i execute function,it changes formatting of text,original text is underlined but it makes it plain. Any ideas? Thanks

My state is different; Original String -> ^tcookie, i want to make first letter after Tabs upper so i replace ^tc -> ^tC
When i do it, final text becomes ^tCookie. How can i fix it?

推荐答案

rng.Find.Format = true;

rng.Find.Format = false;

,它应该可以正常工作.

and it should work.


这篇关于MSWord查找和替换方法更改格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 05:38