create chart slide

Hi,

I am implementing add-in for PowerPoint 2010 with VS2010. Chart slides must be created in this Add-in automatically. I found that I can implement follow type of chart (PowerPoint chart, MSGraph chart, Excel chart) in PowerPoint. The question is witch type of slides apply to PowerPoint the best?

I have chosen the PowerPoint charts but there is a problem by creating a chart with AddChart function of Shapes object. After creating the chart is started the Excel program. But I don’t need Excel and the next question is: how can I disable the starting excel and insert my data in SorceData for chart.

 

Thanks

Iso

Answer
Answer

Hi Steve,

the solution with excel chart and copy past via clipboard works.  This is a part of source code (C#) :

Excel._Workbook oWB;

Excel._Worksheet oSheet;

Excel.Chart oChart;

Excel.Sheets oCheets;

Excel.Range oRange;

Excel._Worksheet oWorkSheet;

Excel.Application oXL;

PowerPoint.Slide objSlide;

 

 

Excel.Application oXL =new Excel.Application ();

oXL.Visible =false ;

oWB = (Excel._Workbook )(oXL.Workbooks.Add(Type .Missing));

oSheet = (Excel._Worksheet )oWB.ActiveSheet;

 

//Add table headers going cell by cell.

oSheet.Cells[1, 1] ="Bezeichnung" ;

oSheet.Cells[1, 2] = "Antwort1" ;

oSheet.Cells[1, 3] ="Antwort2" ;

oSheet.Cells[1,4] ="Antwort3" ;

 

oSheet.Cells[2, 1] = "Werte" ;

oSheet.Cells[2, 2] ="7" ;

oSheet.Cells[2, 3] ="15" ;

oSheet.Cells[2, 4] ="23" ;

 

oSheet.Name =“Tabelle1” ;

oWorkSheet = oXL.ActiveSheet;

oRange = oWorkSheet.get_Range("B1" ,"D2" );

oChart = oXL.Charts.Add();

oChart.HasLegend =false ;

oChart.ChartType = Excel.XlChartType .xl3DColumn;

//Here init objSlide

//...................

System.Windows.Forms.Clipboard .Clear();

oChart.Application.ActiveChart.ChartArea.Copy();

objSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType .ppPasteDefault);

System.Windows.Forms.Clipboard .Clear();

oXL.Quit();

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated September 10, 2020 Views 328 Applies to: