Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I couldn't figure out, how to move (promote, demote) an expression in a chart (Pivot Table) using Macro. The chart.AddExpression method adds the new expression always at the end (as the last), but in my case I want to add an expression before the existing expressions on 1st position.
The method chart.MoveExpression from, to works only on StraightTableObjects, not pivots.
Any ideas how to move the positions of chart expressions?
-Christof
Hi Christof,
you could use MoveExpression - here an example from APIGuide:
rem create new straight table and switch places of expression columns
set chart = ActiveDocument.Sheets("Main").CreateStraightTable
chart.AddDimension "ProductType"
chart.AddExpression "sum(Amount)"
chart.AddExpression "count(Product)"
chart.MoveExpression 1,0
- Marcus
Unfortunately, .MoveExpression method exists only in StraightTable objects, Pivots won’t allow it. As a workaround, I added Fast-Chart-Change types (Straight Table, Pivot Table), change the chart type to straight, make the MoveExpression, then change back. This is a bit tricky …
Thank you
-Christof
Yes, this would be my suggestion for this case then it's quite easy. I think an (worst) alternatively could be to read from the properties all expressions and give them then a new index-number and create the new expression and set the changed properties again ...
- Marcus