Click here to Skip to main content
12,406,592 members (51,092 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# Word Chart

I'm looking at autogenerating a department document and I want to auto generate a chart in this report. The code I got from the internet produces a dated looking chart but I want to be able to use more modern chart. I can find a way of changing styles for Tables but I cant see how I can change a style for a Chart. I'm guessing its something to do with me using MS Chart 8.0 instead of the latest version.

I can see plenty of articles using chart controls in applications but I have to generate this chart in word Programmatically

Code I currently use:
Word.InlineShape oShape;
 object oClassType = "MSGraph.Chart.8";
 wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
 oShape = wrdRng.InlineShapes.AddOLEObject(ref oClassType, ref oMissing,
     ref oMissing, ref oMissing, ref oMissing,
     ref oMissing, ref oMissing, ref oMissing);
 //Demonstrate use of late bound oChart and oChartApp objects to
 //manipulate the chart object with MSGraph.
 object oChart;
 object oChartApp;
 oChart = oShape.OLEFormat.Object;
 oChartApp = oChart.GetType().InvokeMember("Application",
     BindingFlags.GetProperty, null, oChart, null);

 //Change the chart type to Line.
 object[] Parameters = new Object[1];
 Parameters[0] = 4; //xlLine = 4
 oChart.GetType().InvokeMember("ChartType", BindingFlags.SetProperty,
     null, oChart, Parameters);
 //Update the chart image and quit MSGraph.
     BindingFlags.InvokeMethod, null, oChartApp, null);
     BindingFlags.InvokeMethod, null, oChartApp, null);
Would be much appreciated if someone can point me in the right direction
Posted 10-Apr-13 5:01am
Updated 10-Apr-13 5:10am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160730.1 | Last Updated 10 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100