Blank charts in PowerPoint 2007 and Word 2007 after quiting Excel

O

Oliver Bock

My application (C#) creates a whole series of charts (sometimes
hundreds) in PowerPoint 2007 and Word 2007. I find that about one in
twenty of these charts ends up blank, although I can still see the chart
rectangle in the slide/document. (On Word I can edit the chart data and
it fixes itself; on PowerPoint it stays resolutely blank.)

My process is based on "Inserting Excel Charts into PowerPoint 2007"
(http://msdn.microsoft.com/en-us/library/bb676881.aspx), except that I
am creating the chart object entirely within PowerPoint/Word, not
copy+pasting from Excel. I:

1. Create a chart using Shapes.AddChart()
2. Fill in the data via shape.Chart.ChartData.Workbook.ActiveSheet.
3. Use the shape.Chart API to set chart features, apply templates, etc.
4. Close Excel using this sequence from the aforementioned document:

... get rid of any references to Office SDK objects
workbook.Close(false, paramMissing, paramMissing);
excel.Quit();
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();

It is necessary to close Excel after adding each chart because otherwise
the user's taskbar will fill up with many, many Excel instances (Excel
being automatically opened whenever I call Shapes.AddChart().)

I delay the above closing code until I have filled in another few
details in the document, and then I wait 2s, but the problem still occurs.

Any ideas? When doing a similar job with Microsoft Graph as an embedded
document I can call graph.Update(), which ensures everything is good,
but I cannot find anything similar for the new charting API.


Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top