We help IT Professionals succeed at work.

C# Automation in MS Word 2007

Tom Knowlton
Tom Knowlton asked
on
Medium Priority
1,807 Views
Last Modified: 2008-03-17
How do you programmatically insert a pie chart or a bar graph using C# MS Word automation?
I need sample code.
Comment
Watch Question

2007 ? 2003 ?

do you knwo hwo to write code in ms word ?
Tom KnowltonWeb developer

Author

Commented:
MS Word 2007.

It looks like this works:

  //Insert a chart.
            Microsoft.Office.Interop.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);
Tom KnowltonWeb developer

Author

Commented:
Looks like I can tweak this line:

 object oClassType = "MSGraph.Chart.8";
try and we are waiting for your feedback
Tom KnowltonWeb developer

Author

Commented:
It works.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.