c# winword interop在输入文本包含特殊字符或数字字母数字时查找和替换

问题描述

我正在创建一种基于此问题的查找和替换方法: c# word interop find and replace everything

但是当输入有像 [myText] 这样的特殊字符或像 myText0001

这样的数字时它不起作用

Find 对象中是否有允许此操作的设置?

这些是我的设置:

object findText = (object)TextTofind;
object replaceWithText = (object)TextToReplace;
object matchCase = false;
object matchWholeWord = true;
object matchWildCards = false;
object matchSoundsLike = false;
object matchAllWordForms = false;
object forward = true;
object format = false;
object matchKashida = false;
object matchDiacritics = false;
object matchAlefHamza = false;
object matchControl = false;
object read_only = false;
object visible = true;
object replace = 2;
object wrap = 1;

object fileName = (fileNamePath);
aDoc = wordApp.Documents.Open(fileName,ReadOnly: false,Visible: true);
aDoc.Activate();
wordApp.Selection.Find.Execute(ref findText,ref matchCase,ref matchWholeWord,ref matchWildCards,ref matchSoundsLike,ref matchAllWordForms,ref forward,ref wrap,ref format,ref replaceWithText,ref replace,ref matchKashida,ref matchDiacritics,ref matchAlefHamza,ref matchControl);      

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)