This project has moved and is read-only. For the latest updates, please go here.

Add Chart is raising exception

Aug 5, 2013 at 8:09 PM
Hi,

I was able to add shapes , Table etc.
When it comes to AddChart (as shown in code below) it raises exception as shown below.

I am using Office 2013. on Windows 7.
What might be the problem ?

Code:
---snip---
        slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutChartAndText);
        slide.Shapes.AddChart(XlChartType.xlLine);
---snip---

Stack Trace
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
at NetOffice.PowerPointApi.Shapes.AddChart(XlChartType type)
at MyAssembly.Form1.MakePPT(String filename) in c:\work\ACN\App\DV\MyAssembly\Form1.cs:line 74
at MyAssembly.Form1.Form1_Load(Object sender, EventArgs e) in c:\work\ACN\App\DV\MyAssembly\Form1.cs:line 31

Inner Exception

{"Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"}

Regards
Tejasvi
Aug 5, 2013 at 8:38 PM
PowerPoint is a bit strange in automation. make powerpoint visible before and it works.

*Sebastian
Aug 6, 2013 at 6:34 AM
Edited Aug 6, 2013 at 6:35 AM
Thanks a lot! :)

You are right! it works with PowerPoint window open. strange PowerPoint.

Now using
PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue);

instead of
MsoTriState.msoFalse

Regards
Tejasvi