none
Problem of OLE Automation of Powerpoint 2010 with C++ RRS feed

  • Question

  • Hi,

    I'm playing with OLE automation of Powerpoint 2010 recently. I have written a piece of code as shown below. When the line "Shapes.AddPicture..." is executed, I always get an error. Who can tell be where am I wrong.

    By the way, if Powerpoint 2003 is used, the code runs well. Thanks~

    MSPPTApp = new CApplication0();
    MSPPTApp.CreateDispatch(L"Powerpoint.Application");
    CPresentations0 Presentations = MSPPTApp.get_Presentations();
    CPresentation0 Presentation = Presentations.Add(FALSE);
    CSlides0 Slides = Presentation .get_Slides();
    CSlide0 Slide = Slides.Add((long)1, (long)1);
    CShapes0 Shapes = Slide.get_Shapes();
    Shapes.AddPicture(L"E:/image1.jpg", msoTrue, msoTrue, 0.0f, 0.0f, 100.0f, 100.0f);
    Presentation.SaveAs(L"E:/1.pptx", ppSaveAsOpenXMLPresentation, 0);



    Tuesday, November 26, 2013 1:43 PM

Answers

  • Hello,

    It looks like the picture you specified cannot be found by PowerPoint. 

    Please try to change the file path in the following way:

    Shapes.AddPicture(L"E:\image1.jpg", msoTrue, msoTrue, 0.0f, 0.0f, 100.0f, 100.0f);
    Presentation.SaveAs(L"E:\1.pptx", ppSaveAsOpenXMLPresentation, 0);
    Please let me know whether it helps.

    • Marked as answer by XFOOLISH Thursday, November 28, 2013 9:01 AM
    Tuesday, November 26, 2013 2:03 PM

All replies

  • Hello,

    It looks like the picture you specified cannot be found by PowerPoint. 

    Please try to change the file path in the following way:

    Shapes.AddPicture(L"E:\image1.jpg", msoTrue, msoTrue, 0.0f, 0.0f, 100.0f, 100.0f);
    Presentation.SaveAs(L"E:\1.pptx", ppSaveAsOpenXMLPresentation, 0);
    Please let me know whether it helps.

    • Marked as answer by XFOOLISH Thursday, November 28, 2013 9:01 AM
    Tuesday, November 26, 2013 2:03 PM
  • I'm really surprised that the problem is the path separator. After I change it to backslash, it works, thanks for you help, Eugene_Astafiev~
    Thursday, November 28, 2013 9:07 AM