VSTO Powerpoint加载项-如何将图片添加到sliede

问题描述 投票:0回答:2

我试图通过单击VSTO PP AddIn中的TaskPanel按钮来添加图片,该代码在WinForms中有效。

现在,我尝试使用Xaml主机集TaskPanel实现此功能,但是它无法正常工作(相同的代码)。

它不会编译,但不会显示错误:

public void AddImageToSlideEvent(object sender, EventArgs e)
    {
        //Cast sender as button for tag attribute
        Button button = sender as Button;

        Powerpoint.Application presentation = Globals.ThisAddIn.Application;



        //save current slide in "currentSlide"
        var currentSlide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;

        //TODO: Add Picture does not work
        Powerpoint.Shape shape = currentSlide.Shapes.AddPicture(button.Tag, true, true, 250, 250);
    }

谁可以在这里帮助您?

很多东西

c# vsto office-interop
2个回答
0
投票
以下示例显示您需要传递图片的路径和文件名。

myDocument.Shapes.AddPicture FileName:="c:\microsoft office\" & _ "clipart\music.bmp", LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, _ Left:=100, Top:=100, Width:=70, Height:=70


0
投票
所以我开始了一个新的测试AddIn-旧代码有效:),但我不知道出了什么问题。

但是感谢您的帮助!

© www.soinside.com 2019 - 2024. All rights reserved.