Search code examples
c#vstopowerpoint-2010

Is there a way to embed an image with the add-in file in PowerPoint 2010 using C# VSTO?


I want to put an image file on a custom slide which is being created on the click of a custom button.

As I have applied image icons on the custom button through Resources folder of my application, is there a similar way I can put the image on the slide referencing the Resources folder, so that I need not mention the full path of the image file in the Slide.Shapes.AddPicture() method?

I am using C# VSTO to build the application.

Thanks.


Solution

  • Did it using the below code:

    Image badge = Addin1.Properties.Resources.img; 
    String path = Path.Combine(Path.GetTempPath (), "img.png"); 
    badge.Save(path);
    

    Remove the image after the image has been pasted on the slide, delete the image from the above path.

    File.Delete(path);