I am trying to change the text color of the chart title of a histogram chart in PowerPoint.
Here is what I do:
var colorFormat = chart.ChartTitle.Format.TextFrame2.TextRange.Font.Fill.ForeColor;
colorFormat.RGB = ...;
// or
colorFormat.ObjectThemeColor = ...;
This works for the standard charts like line charts. But it doesn't work for other chart types like histogram, waterfall, tree map etc.
In these cases, setting ObjectThemeColor
sets the text to black. Setting RGB
does actually set the correct color. However, in both cases, as soon as the user changes the selection, the text color jumps back to the one it had previously.
How can I set the text color of the title of one of these charts?
I am using VSTO and C# but a VBA solution is just as welcome as long as it can be translated to C# and still work.
Slides[1].Shapes[2].Chart
) I am able to apply the color to the chart title without losing the change. Are you using theSelection
object to identify the chart instead of other means such as theShape.Name
property? That might explain the loss of the color change when the user changes the selection. – joeschwacolorFormat.RGB = Color.DarkOliveGreen.ToArgb()
) It may be possible that VSTO requires this. – joeschwaActivePresentation.Slides(19).Shapes(2).Chart.ChartTitle.Characters.Font.Color = vbGreen
has the exact same result: 1. It works only if the chart title is selected 2. It reverts back once something else gets selected. – Daniel Hilgarth