none
Creating SmartArt in PowerPoint RRS feed

  • Question

  • Hello Cindy,

    I'm having trouble in creating the smartarts for powerpoint, in which the error shows as follows: 

    Unhandled Exception: System.Runtime.InteropServices.COMException: Application (unknown member) : Object does not exist.
    at Microsoft.Office.Interop.PowerPoint.ApplicationClass.get_SmartArtLayouts()
    at ConsoleApplication2.Program.Main(String[] args) in c:\users\jovial\documents\visual studio 2010\Projects\ConsoleAp
    plication2\ConsoleApplication2\Program.cs:line 33

    I was hoping that you could help me solve this issue. Below shows the code I've done for it.

    PowerPoint.Application oPowerPoint = null;
    PowerPoint.Presentations oPres = null;
    PowerPoint.Presentation oPre = null;
    PowerPoint.Slides oSlides = null;
    PowerPoint.Slide oSlide = null;
       
    oPowerPoint = new PowerPoint.Application();

    oPres = oPowerPoint.Presentations;
    oPre = oPres.Add(Office.MsoTriState.msoFalse);
    oSlides = oPre.Slides;
    oSlide = oSlides.Add(1, PowerPoint.PpSlideLayout.ppLayoutText);
    Office.SmartArtLayout myLayout = oSlide.Application.SmartArtLayouts[1];

    Console.WriteLine(myLayout.Name);

    I would really appreciate, if you could support me on this issue.

    Thank you. :D

    • Split by Cindy Meister MVPModerator Tuesday, July 30, 2013 6:04 AM Split for better visibility to General Office Dev because not VSTO from http://social.msdn.microsoft.com/Forums/vstudio/en-US/6f31f9ed-aed0-4251-81f8-8cac80d86b83/how-to-add-a-smart-art-to-powerpoint-presentation-using-c-code
    Tuesday, July 30, 2013 4:06 AM

Answers

  • Hi Kevin,

    I can reproduce your issue on my lab machine.

    Currently, I found this issue will happen when I add a new PPT document instead of opening an existed one.

    I’m still looking for root cause of this issue and it will take some time, I will keep you being informed if I have any updates.

    In the meantime, I would like to provide you a workaround solution:

    oPowerPoint = new PowerPoint.Application();
    oPres = oPowerPoint.Presentations;
    oPre = oPres.Add(Office.MsoTriState.msoFalse);
    oPre.SaveAs(@"C:\tem\a.ppt");
    oPre.Close();
    oPre = oPres.Open(@"C:\tem\a.ppt");
    oSlides = oPre.Slides;
    oSlide = oSlides.Add(1, PowerPoint.PpSlideLayout.ppLayoutText);
    Office.SmartArtLayout myLayout = oSlide.Application.SmartArtLayouts[1];
    Console.WriteLine(myLayout.Name);


    Friday, August 2, 2013 9:18 AM