Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
justinasp
Creator
Creator

Set expression "Conditional" show in macros

Hello all,

does anyone know if it is possible to set an option "Conditional" (+some condition) for the Expression in Chart Properties by Macros?

example.jpg

Thanks in advance!

Sincerely,

Justinas

1 Solution

Accepted Solutions
justinasp
Creator
Creator
Author

Made it!

Sub ExpressionEnableCondition

    Set chart = ActiveDocument.GetSheetObject("CH01")

    Set cp = chart.GetProperties

    Set expr = cp.Expressions

    Set expr_data = expr.Item(0).Item(0).Data.EnableCondition

    expr_data.Type = 2

    expr_data.Expression = "here_goes_your_expression"

    chart.SetProperties cp

End Sub

View solution in original post

3 Replies
fosuzuki
Partner - Specialist III
Partner - Specialist III

Hi, found this in API Guide:

CLASS = ICondExDef

MEMBER = Expression

EXAMPLE:

set chart=ActiveDocument.GetSheetObject("CH01")

set cp=chart.GetProperties

set dims=cp.Dimensions

set expr=cp.Expressions.Item(0).Item(0).Data.ExpressionData

dims(0).Show.Type=1 '0=false, 1=true, 2=cond

expr.Show.Type=2

expr.Show.Expression="sum(a)<10000"

chart.SetProperties cp

Hope this helps

Fernando

justinasp
Creator
Creator
Author

This won't work for me. Your example controls Columns Presentation option:

wrong_example.jpg

What I need is a different thing.

justinasp
Creator
Creator
Author

Made it!

Sub ExpressionEnableCondition

    Set chart = ActiveDocument.GetSheetObject("CH01")

    Set cp = chart.GetProperties

    Set expr = cp.Expressions

    Set expr_data = expr.Item(0).Item(0).Data.EnableCondition

    expr_data.Type = 2

    expr_data.Expression = "here_goes_your_expression"

    chart.SetProperties cp

End Sub