I’m having an issue selecting & editing a 2nd Excel graph object in a Word document.
I have a C# application, developed in Visual Studio 2010. Earlier I have the code:
// Excel objects.
Word.InlineShape pieShape = wrdDoc.InlineShapes[1];
if (pieShape.OLEFormat.ProgID == "Excel.Chart.8")
{
// Ensure object is running.
object verb = Word.WdOLEVerb.wdOLEVerbHide;
pieShape.OLEFormat.DoVerb(verb);
xlPieWrkBk = (Excel._Workbook)pieShape.OLEFormat.Object;
xlPieDataWrkSht = xlPieWrkBk.Worksheets["DX"]; // 'DX' is the name of the data worksheet for the displayed pie graph.
}
and is successfully able to update xlPieDataWorkSht which updates the pie graph.
However, I have a 2nd graph later in the same Word document.
Code
Word.InlineShape pieShape = wrdDoc.InlineShapes[2];
Doesn’t work. In fact wrdDoc.InlineShapes only appears to have one object.
How do I access the 2nd graph in the document.
or
Is it possible to have both graphs use the same set of data instead of updating 2 separate worksheets of data?
The 2nd graph wasn’t an ‘inline’ object, the format was floating. Once I changed the formatting it’s working fine