ChartUpdater removes style on columns

Home Forums PresentationML ChartUpdater removes style on columns

This topic contains 3 replies, has 2 voices, and was last updated by  noxrep 1 year, 11 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #3416


    Hello Eric,

    I have been working on automating PowerPoint presentations through VB.NET for a while now, and I’m close to completion. Your site has helped me a lot with some parts of the project, but there is one thing I can’t seem to figure out or find an answer to.

    I have used the ChartUpdater.UpdateChart function from PowerTools to update the charts on each slide. This only appears to change the visual part of the chart, however, as the worksheet behind the chart remains at default values. If someone clicks “Edit Data” in the PowerPoint, the chart will suddenly update to reflect this. I wrote my own script to update the embeddedPackagePart, and that works, but I thought ChartUpdater was supposed to edit the worksheet too?

    In either case, the main problem that remains now is that no matter which method I use to update the chart, the bars or lines will all be set to use the same color. Normally there are three lines being drawn, using a custom color style my company has added to the PowerPoint. After calling ChartUpdater.UpdateCharts, the lines will have the correct values but only the first color of the chart style is used.

    chartData = New ChartData()
    With chartData
        .SeriesNames = {"Income", "Costs", "Result"}
        .CategoryDataType = ChartDataType.String
        .CategoryNames = categoryNames ' array of type String
        .Values = New Double()() { ' each series is their own array of type Double
    End With
    ChartUpdater.UpdateChart(chartPart, chartData)

    I tried getting the existing ChartStyle, ChartColorStyle, etc. from the ChartPart beforehand, and and then setting them on the chart after calling the update, but this does not appear to do anything.

    The presentation uses mostly bar charts and line charts. There is a single pie chart on the last slide – this uses the same ChartData as one of the earlier charts, but curiously enough it keeps the correct color styles/formatting.

    Do you have any idea what I could do to fix this?

    Thank you in advance for any help.



    Update: I have set the chart colors by accessing

    ChartPart -> ChartSpace -> BarChart -> BarchartSeries -> SolidFill .-> SchemeColor -> SchemeColorValues

    However, when I set this value – even if I set it to an existing color such as SchemeColorValues.Accent3 – it will lock the color in the presentation. When I later open the finished file and change the theme via the Design tab, the chart’s color will stick around even as the entire rest of the presentation changes to fit the new theme’s color palette.

    I thought that setting the color to one from the SchemeColorValues enum would allow the color to change with the theme, but apparently this does not happen.


    Eric White

    I am quite sure that there is a difference in markup between setting the color directly, and setting the color to one of the colors of the theme. Unfortunately, I don’t know what the difference is without doing the research.

    I would take the approach of creating a presentation that uses one of the colors of the theme, saving it, copying it, then changing the copy to use a different one of the colors of the theme, and then using the Open Xml SDK Productivity Tool to compare the two, thereby finding out how to change the color to use any of the colors of the theme. This process is demonstrated in the following screen-cast.

    Please let me know how you get on.




    Thank you for your reply. We put the color issue aside for a while to work on other things, but now that I’ve come back to it I managed to fix the problem.

    After running ChartUpdater, the issue with only the first theme color being used for all series persisted. I then set the colors by changing the value of SchemeColor. As I mentioned in my second post, this worked but appeared to lock the chart to always use those colors.

    When I used the Productivity Tool to look over the file, the only references I could find to specific color values were in our custom theme definition; the actual charts used values like “Accent1” and so on. After changing the theme, however, there would be two themes defined in the document, with some charts using the original and others using the new theme.

    As it turns out, the template we were using already had its colors locked. This must have happened at some point while the template was being updated by our designer, and from what I can find on the ‘net this seems to be a relatively common issue with custom presentation themes. After going over the charts in the template and resetting them to default styles, we were able to shake off the “stuck” formatting.

    We then reapplied out custom theme, and everything seems to work now. When we export our reports, the theme can now be changed without any formatting from the original theme staying behind.

    Thank you for your time.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.