【问题标题】:How to find and modify a TextBox in some word document using Microsoft.Office.Interop.Word?如何使用 Microsoft.Office.Interop.Word 在一些 word 文档中查找和修改 TextBox?
【发布时间】:2012-01-15 09:16:09
【问题描述】:

我必须通过 TextBox id 访问和更改某些 word 文档的某些文本框的文本。 例如,假设我在 word 文档中有一些名为 txtDate 的对象,我想将其内容更改为现在的日期,那么如何通过其 id 获取该对象?

【问题讨论】:

    标签: c# visual-studio ms-word office-interop


    【解决方案1】:
    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;
                }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-21
      • 1970-01-01
      • 2014-12-11
      • 1970-01-01
      • 1970-01-01
      • 2021-04-27
      • 1970-01-01
      相关资源
      最近更新 更多