如何使用Interop C#或VB替换Word 2013+中的图片内容控件中的现有图片

时间:2017-03-14 19:42:12

标签: c# ms-word interop

我正在使用Word 2013.我转到开发人员选项卡,在我的文档中添加“图片内容控件”。将其标题设置为“徽标”。然后,单击控件并设置默认图像。

我的问题是如何使用Word Interop替换任何其他图像的默认图像(请不要使用OpenXML),语言可以是C#或VB无关紧要。

using Microsoft.Office.Interop.Word;

ContentControls controls = d.SelectContentControlsByTitle("logo");
foreach (ContentControl c in controls)
{
    if (c.Type == WdContentControlType.wdContentControlPicture)
    {                        
        // ContentControl of Interop.Word doesn't have Image property
        // Couldn't cast the Microsoft.Office.Tools.Word.PictureContentControl either
    }
}

1 个答案:

答案 0 :(得分:0)

您可以像这样替换图片

<div>
  Demo
 </div>
相关问题