如何在C#中的Footer of Word文档中查找和替换字符串? [英] How to find and replace string in Footer of Word document in C#?

查看:150
本文介绍了如何在C#中的Footer of Word文档中查找和替换字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#中的Footer of Word文档中查找和替换字符串?

How to find and replace string in Footer of Word document in C#?

推荐答案

c#4.0 - 使用Interop替换Word中页眉和页脚中的字段 - 堆栈溢出 [ ^ ]


非常感谢你。但是下面的代码解决了我的问题



Thank you so much. but the below code solved my problem

object replaceAll = MSWord.WdReplace.wdReplaceAll;

foreach (Microsoft.Office.Interop.Word.Section section in oDoc.Sections)
{
      Microsoft.Office.Interop.Word.Range footerRange = section.Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
      footerRange.Find.Text = "Some Text";
      footerRange.Find.Replacement.Text = "Replace Text";
      footerRange.Find.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);
                    }


这篇关于如何在C#中的Footer of Word文档中查找和替换字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆