首页 > 解决方案 > 使用 ContentControl 将图片附加到 Word

问题描述

我在一些内容控件中有一个 word 模板文件,其中一个是图片内容控件,用sign 标记。我在这里阅读了许多文档和一些类似我的问题,并找到了一些类似这样的代码,但它只是不起作用并且不将图片添加到文档中,我不明白问题出在哪里。

 public void AddSignHidden(Microsoft.Office.Interop.Word._Document Doc, string SignImagePath)
        {

            ContentControls Ccontrol = Doc.SelectContentControlsByTag("__sign");

            foreach (ContentControl nativeControl in Ccontrol)
            {
                nativeControl.Range.InlineShapes.AddPicture(SignImagePath, Type.Missing, true, Type.Missing);
            }

            Doc.Save();
            Doc.Close();
            Doc = null;

        }

标签: c#imagewordcontentcontrol

解决方案


推荐阅读