【问题标题】:Populating Content Control in Word document with C#使用 C# 在 Word 文档中填充内容控件
【发布时间】:2015-08-14 20:29:39
【问题描述】:

我有一个 Word 模板 (*.dotx) 我正在尝试使用 C# 填充。

我无法访问模板中的“纯文本内容控件”。

以下代码添加(打开)文档,但始终显示 0 个表单域。

参考文献:

using Application = Microsoft.Office.Interop.Word.Application;
using Document = Microsoft.Office.Interop.Word.Document;

功能代码:

var word = new Application();
var doc = new Document();
doc = word.Documents.Add(Directory.GetCurrentDirectory() +
             @"\..\..\Media\Documents\MCO Notification of a Medicaid Other Event - Template.dotx");
doc.Activate();

MessageBox.Show(doc.FormFields.Count.ToString());

doc.Close();
word.Quit();

另外,如何在应用程序中插入文档的相对路径。

【问题讨论】:

    标签: c# wpf ms-word


    【解决方案1】:

    您必须使用FlowDocument 来容纳 Word 文档中的 RTF。

    搜索有关“在 WPF FlowDocument 中显示 Word 文档”的解决方案。

    类似这样的: http://www.codeproject.com/Articles/649064/Show-Word-File-in-WPF

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-27
      • 1970-01-01
      • 2010-12-23
      • 1970-01-01
      相关资源
      最近更新 更多