【问题标题】:Insert image file to publisher document in place of existing image将图像文件插入到发布者文档中以代替现有图像
【发布时间】:2017-05-23 08:26:46
【问题描述】:

我有发布者文档用作模板。

如何从文件中插入图片来代替“?”图片。

可能与 MS Word 的方法相同,但我找不到。

我以这种方式访问​​该模板:

using Publisher = Microsoft.Office.Interop.Publisher;

Publisher._Application pubApp = new Publisher.Application();
Publisher.Document doc = pubApp.Open(docPath);
Publisher.Page templateCard = doc.Pages[1];

【问题讨论】:

    标签: c# ms-office office-interop ms-publisher


    【解决方案1】:

    基本上:

    shape.PictureFormat.Replace(filePath);
    

    找到我想出的模板图像的最佳方法是为我的图像设置替代文本并对其进行破解:

    foreach (Publisher.Shape shape in currenPage.Shapes) {
        if (shape.AlternativeText == "DICKBUTT")
            //here you do your stuff
    }
    

    【讨论】:

    • 干得好!您也可以从 VBA 中设置形状的 .Name 属性并检查它(这通常是在 Publisher 代码中识别形状的最简单方法)。
    猜你喜欢
    • 2012-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多