Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ysiroong
Contributor III
Contributor III

VBScript Member for Expression Background Color

Does anyone know the VB syntax is to set the background color for an expression?

For instance, if I want to write a macro to set the expression definition I would write:


Set tbl = ActiveDocument.GetSheetObject("table")
Set exp = tbl.GetProperties
Set definition = exp.Expression.Item(0).Item(0).Data.ExpressionData.Definition
definition.v = "Sum(variable)"


How would I do the same thing to set the background for that expression? I tried the APIGuide but can't seem to find any answers there.

1 Solution

Accepted Solutions
ysiroong
Contributor III
Contributor III
Author

I found the member. It's AttributeExpressions under the IExpressionDataEx class. From the APIGuide:


set chart = ActiveDocument.Activesheet.CreatePivotTable
chart.AddDimension "ProductType"
chart.AddExpression "sum(Amount)"
set cp = chart.GetProperties
set expr = cp.Expressions.Item(0).Item(0).Data
set bce = expr.AttributeExpressions.BkgColorExp
bce.Definition.v = "if(ProductType='Soap', red(), yellow())"
chart.SetProperties cp


View solution in original post

3 Replies
Not applicable

Hi, I have not tried this but I think this will do the trick: (this is from the APIGuide; not sure if you already tried this).

set chart = ActiveDocument.ActiveSheet.CreateStraightTable
chart.AddDimension "Customer"
chart.AddDimension "ProductType"
chart.AddExpression "sum(Amount)"
set cp = chart.GetProperties
set expr = cp.Expressions.Item(0).Item(0).Data.ExpressionVisual
expr.Label.v = "Sales"
expr.LabelAdjust = 2
expr.VisualCues.LowLimit.v = 10
expr.VisualCues.LowCue.Color.Col = RGB(255,0,0) 'red
expr.VisualCues.LowCue.FontStyleMod = 2 'bold
expr.VisualCues.LowCue.SizeMod = 1 '+20%
chart.SetProperties cp

ysiroong
Contributor III
Contributor III
Author

I found the member. It's AttributeExpressions under the IExpressionDataEx class. From the APIGuide:


set chart = ActiveDocument.Activesheet.CreatePivotTable
chart.AddDimension "ProductType"
chart.AddExpression "sum(Amount)"
set cp = chart.GetProperties
set expr = cp.Expressions.Item(0).Item(0).Data
set bce = expr.AttributeExpressions.BkgColorExp
bce.Definition.v = "if(ProductType='Soap', red(), yellow())"
chart.SetProperties cp


a_yershov
Contributor II
Contributor II

Thanks, dude! You've saved me!