Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a chart which I want to be able to change the color dynamically, I spotted the following piece of code in the API
set Graph = ActiveDocument.Sheets("Main").CreateBarChart
Graph.AddDimension "ProductType"
Graph.AddExpression "sum(Amount)"
Graph.AddBkgColorExpression "if(sum(Amount)>10,green(),red())",0
but it doesnt actually alter the background expression, can anyone advise how to get it to change the actual background color expression.
Thanks
Heya,
If you want to change the expression on a dimension or expression you can do something along the lines of this:
sub AnyOldMacroName
set chart = ActiveDocument.GetSheetObject("CH01")
set cp = chart.GetProperties
set dims = cp.Dimensions
set bce = dims(0).AttributeExpressions.BkgColorExp
bce.Definition.v = "if(Sum(Sales)>1000, LightGreen(), LightRed())"
chart.SetProperties cp
end sub
//Johannes
Heya,
If you want to change the expression on a dimension or expression you can do something along the lines of this:
sub AnyOldMacroName
set chart = ActiveDocument.GetSheetObject("CH01")
set cp = chart.GetProperties
set dims = cp.Dimensions
set bce = dims(0).AttributeExpressions.BkgColorExp
bce.Definition.v = "if(Sum(Sales)>1000, LightGreen(), LightRed())"
chart.SetProperties cp
end sub
//Johannes
Exellent Johannes, thanks.
Forgot to mention is there anywhere that you can actually get a list of each of the different properties.
Thanks again