c#Interop.Word Find.在Word doc的文本框内执行

c#Interop.Word Find.在Word doc的文本框内执行,c#,ms-word,C#,Ms Word,我正在使用FindAndReplace类似的内置函数将word文档中的某些文本替换为新文本。但是当想要的文本在文本框中时,函数似乎找不到它 我的代码: object matchCase = true; object matchWholeWord = true; object matchWildCards = false; object matchSoundLike = false; object nmatchAllforms = false; object forward = true; obj

我正在使用FindAndReplace类似的内置函数将word文档中的某些文本替换为新文本。但是当想要的文本在文本框中时,函数似乎找不到它

我的代码:

object matchCase = true;
object matchWholeWord = true;
object matchWildCards = false;
object matchSoundLike = false;
object nmatchAllforms = false;
object forward = true;
object format = true;
object matchKashida = false;
object matchDiactitics = false;
object matchAlefHamza = false;
object matchControl = false;
object read_only = false;
object visible = true;
object replace = 2;
object wrap = 1;

var range = myWordDoc.Range();

//Finds the parameter, then replaces
range.Find.Execute("replaceable",
ref matchCase, ref matchWholeWord,
ref matchWildCards, ref matchSoundLike,
ref nmatchAllforms, ref forward,
ref wrap, ref format, "value",
ref replace, ref matchKashida,
ref matchDiactitics, ref matchAlefHamza,
ref matchControl);
有一个选项可以检查文件中的所有文本框并调用内部文本的函数? (实际上没有用这样的新文本替换里面的整个文本:)


提前谢谢你

shape.TextFrame.TextRange返回一个
Range
对象,因此在文档中循环
Shapes
,测试类型是否为文本框,然后

var rngTextBox = shape.TextFrame.TextRange;

//Finds the parameter, then replaces
rngTextBox.Find.Execute("replaceable", //etc.
var rngTextBox = shape.TextFrame.TextRange;

//Finds the parameter, then replaces
rngTextBox.Find.Execute("replaceable", //etc.