Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 ysiroong
		
			ysiroong
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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.
 ysiroong
		
			ysiroong
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
 
					
				
		
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
		
			ysiroong
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
		
			a_yershov
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Thanks, dude! You've saved me!
