我必须通过TextBox id访问和更改某些word文档的某些文本框的文本。例如,假设我在word文档中有一个名为txtDate的对象,并且我想将其内容更改为现在的日期,那么我如何通过其id获取此对象?
void SearchTextBox(Word.Document oDoc,string name,string newContent)
{
foreach (Word.Shape shape in oDoc.Shapes)
if (shape.Name == name)
{
shape.TextFrame.ContainingRange.Text = newContent;
return;
}
}