Moh*_*sen 1 c# ms-word office-interop visual-studio
我必须通过 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;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6771 次 |
| 最近记录: |