Creating charts in PowerPoint 2007 using the SP2 Charting API

O

Oliver Bock

Hi,

I am trying to create standalone charts in PowerPoint 2007 using the
charting API that was exposed as part of Office 2007 service pack 2. It
mostly works, but I am finding it to be flaky. In particular, sometimes
my charts come up blank and sometimes they have corrupted series. When
I generate charts repeatedly they sometimes all work, but usually about
one in 20 has a problem.

I guess that I am doing something wrong, but I can find little overview
documentation.

My questions are:

- Are there any more extensive samples than the fragments in

http://blogs.msdn.com/officedevdocs...art-object-model-in-powerpoint-and-word.aspx?
I have found http://msdn.microsoft.com/en-us/library/bb676881.aspx,
but it is really about pasting from Excel, which is not what I want.

- Is there any way to stop Excel popping up whenever a chart is
inserted? I insert many (sometimes hundreds) charts.

- If not, is there a proper way to shut down the Excel windows that pop
up? Should I close the workbook after each to avoid Excel being
started repeatedly?

- What is the correct way to clear the sample data that appears?
I don't use Range.ClearContents() because that gets rid of the
draggable rectangle that lets users easily control which parts
of the data to plot. Instead I just set each cell's formula to
an empty string.

- Using SetSourceData also removes the draggable rectangle that lets
the user easily control which parts of the data to plot. This is a
nuisance to my users because they often want to edit the charts after
creating them. I have found that I can control this rectangle by
calling Resize on the first (and only) ListObject in the Worksheet.
Is this kosher?
 
C

Colbert Zhou [MSFT]

Hello Oliverbock,

Here is a nice article with codes sample about how to insert charts in Word
and Powerpoint based on the SP2 feature,
http://blogs.msdn.com/vsod/archive/2009/06/15/creating-charts-in-word-and-po
werpoint-using-newly-introduced-object-model-in-office-2007-service-pack-2.a
spx

To your questions,
-------------------------------------------------------inserted? I insert many (sometimes hundreds) charts.

We can hide the popping up Excel Window by setting,
Word.ChartData.Workbook.Application.Visible to false.

-------------------------------------------------------up? Should I close the workbook after each to avoid Excel being
started repeatedly?

We can quit the Excel application using the same way,
Word.ChartData.Workbook.Application.Quit()
(The last line of codes in my referenced link)

-------------------------------------------------------I don't use Range.ClearContents() because that gets rid of the
draggable rectangle that lets users easily control which parts
of the data to plot. Instead I just set each cell's formula to
an empty string.the user easily control which parts of the data to plot. This is a
nuisance to my users because they often want to edit the charts after
creating them. I have found that I can control this rectangle by
calling Resize on the first (and only) ListObject in the Worksheet.
Is this kosher?

Actually, the same as answers to the above questions. Since we get the
Workbook object of Excel, we can change each cell's value. And if we want
to re-select the datasource, we can just resize the ListObject as you
found. The codes are also included in my referenced link.

Hope this helps!


Best regards,
Ji Zhou
Microsoft Online Community Support
 
O

Oliver Bock

Hi again Ji,

Thanks for your link to that excellent article, and thanks for your
help. I also just found this other article:
http://blogs.msdn.com/excel/archive/2009/08/18/chart-object-model-in-word-powerpoint.aspx
We can hide the popping up Excel Window by setting,
Word.ChartData.Workbook.Application.Visible to false. ....
We can quit the Excel application using the same way,
Word.ChartData.Workbook.Application.Quit()
(The last line of codes in my referenced link)

I am also worried about the system resources used up by hundreds of open
workbooks. Therefore I take this approach:

1. After each chart is complete I call close on the Workbook object.
2. After all charts are exported I call Quit on the Excel Application
object.

Regards,
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