Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I need change the order of a graphic when i press a button, is posible?
I have the next code in a function:
'First set a variable with the object type graphic
set obj = ActiveDocument.GetSheetObject("CH12")
'Then set the properties of the graphic
set p = obj.GetProperties
'Find the expressions
set expr = p.Expressions.Item(0).Item(0).Data.ExpressionVisual
AND THEN??
i see "expr.ExpressionTypes(0).Order = 3" in a forum but not result
Hi Felipe,
i think that to change the graphic order you must change the order of dimension(s) not to the expression. Below is a quick example how to change the sorting of a chart to "Expression" with remove all other sorts: (example for each sorting can be found in ApiGuide.qvw
sub ChangeSorting
set chart=ActiveDocument.GetSheetObject("CH02")
set Prop = chart.GetProperties
set vars = Prop.Dimensions
for i = 0 to vars.Count-1
vars.Item(i).SortCriteria.SortByLoadOrder = 0
vars.Item(i).SortCriteria.SortByAscii = 0
vars.Item(i).SortCriteria.SortByFrequency = 0
vars.Item(i).SortCriteria.SortByLoadOrder = 0
vars.Item(i).SortCriteria.SortByNumeric = 0
vars.Item(i).SortCriteria.SortByState = 0
'These two dont work for pivot table
'vars.Item(i).SortCriteria.SortByYValue = 0
'vars.Item(i).SortCriteria.SortByApplicability = 0
vars.Item(i).SortCriteria.SortByExpression = 1
vars.Item(i).SortCriteria.Expression.v = "sum(Qty)"
next
chart.SetProperties Prop
end sub
Stefan
Hi Felipe,
i think that to change the graphic order you must change the order of dimension(s) not to the expression. Below is a quick example how to change the sorting of a chart to "Expression" with remove all other sorts: (example for each sorting can be found in ApiGuide.qvw
sub ChangeSorting
set chart=ActiveDocument.GetSheetObject("CH02")
set Prop = chart.GetProperties
set vars = Prop.Dimensions
for i = 0 to vars.Count-1
vars.Item(i).SortCriteria.SortByLoadOrder = 0
vars.Item(i).SortCriteria.SortByAscii = 0
vars.Item(i).SortCriteria.SortByFrequency = 0
vars.Item(i).SortCriteria.SortByLoadOrder = 0
vars.Item(i).SortCriteria.SortByNumeric = 0
vars.Item(i).SortCriteria.SortByState = 0
'These two dont work for pivot table
'vars.Item(i).SortCriteria.SortByYValue = 0
'vars.Item(i).SortCriteria.SortByApplicability = 0
vars.Item(i).SortCriteria.SortByExpression = 1
vars.Item(i).SortCriteria.Expression.v = "sum(Qty)"
next
chart.SetProperties Prop
end sub
Stefan
Thanks Stefan, i will try, and thinking, you have the reason about the dimensions.