Insert Image in Powerpoint template in C# RRS feed

  • Question

  • Hi ,

    I have power point slide in which i am trying to insert image ,but haven't found any relevant option here is my code snippet


      objApp = new PowerPoint.Application();
                objApp.Visible = MsoTriState.msoTrue;
                objPresSet = objApp.Presentations;
                objPres = objPresSet.Open(strTemplate,
                    MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
                objSlides = objPres.Slides;


     objSlide = objSlides.Add(1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);
                //objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
               objSlide.Shapes.AddPicture(strPic, MsoTriState.msoFalse, MsoTriState.msoTrue,
                    150, 150, 500, 350);


    please if any one can help me out ,its urgent


    Amit Tiwari

    Saturday, April 16, 2011 1:26 AM

All replies

  • Amit,

    Please tell us the problem you are facing. The code is pretty straight forward, but until you tell us the problem, we wont be able to debug it further.


    Sunday, April 17, 2011 6:59 AM
  • Hi ,

    Thanks for your reply

    I have power point template and in that i have given the header text , below that i wanna to insert image what ever  i want ,in inserting image code is running but new slide is creating but i wanna insert image in the existing slide.

    I am not sure that this code is f9 or not if u have code for this ,it will be gr8 help for  me


    Amit Tiwari


    Monday, April 18, 2011 9:19 PM
  • Hi Amit,

    It is late, but someone might be able to get the benefit with that, so posting the solution.

    In your code, you have mentioned

     objSlide = objSlides.Add(1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);

    Since you are using the add method it is adding the slide.

    For accessing the current slide, I would use something like (not tested, just a hint)  :

    objSlides = objApp.ActiveWindow.Selection.SlideRange[1];
    If you insert the image on the above objSlide object, then it will insert the image on active slide only.


    Sorry for being late :)

    Vikas B

    My Blog My Profile
    • Proposed as answer by Dot_Net_Noob Monday, September 5, 2011 6:04 AM
    Tuesday, August 30, 2011 12:18 PM