I need to programmatically insert, or edit, a pie chart in a Word 2007 document, using vs 2010, c# ... everything i have found shows how to put these old ugly charts into a word doc. so i am now wondering if it is even possible to manipulate the newer and better looking charts.
this one shows how to do just what i want, only it's the old ugly charts.... http://msdn.microsoft.com/en-us/library/ms178766.aspx. It tells you to insert a OLE object, and it's the ancient msgraph.chart.8 stuff.
i've been able to do everything i need to do except use the newer style of charts.
Here's some of the code. I built a new pie chart and now how do I insert it into the Word document? my PieChart3D class is based on these http://code.msdn.microsoft.com/mschart
// here's my c#.net
private void CreateChart(string title, Microsoft.Office.Interop.Word.Application oWord, Microsoft.Office.Interop.Word.Document oDoc, ChartType chartType, Hashtable values) { PieChart3D chart1 = new PieChart3D(); // using System.Windows.Forms.DataVisualization.Charting chart1.PieChart3D_Load(values);
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
Microsoft.Office.Interop.Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
// None of these work!!!!
wrdRng.InlineShapes.AddOLEControl(chart1);
wrdRng.InlineShapes.AddChart(chart1);
wrdRng.InlineShapes.AddOLEObject(chart1);
return;
}
// done with code
It seems to me I only need the last step of injecting it into the document. What am I missing?
Thanks, willgroove