Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro for sort order in chart

Hi,

I run into problems when I try to create a macro to set the sort order in a chart .

The follwoing code works fine:


Set chart = ActiveDocument.GetSheetObject("CH10")
Set prop = chart.GetProperties
Prop.Dimensions(0).SortCriteria.SortByAscii = 0
Prop.Dimensions(0).SortCriteria.SortByExpression = 0
Prop.Dimensions(0).SortCriteria.SortByFrequency = 0
Prop.Dimensions(0).SortCriteria.SortByLoadOrder = 0
Prop.Dimensions(0).SortCriteria.SortByState = 0

But when I test with this:

Prop.Dimensions(0).SortCriteria.SortByYValue = 0

I get an error telling me that "SortByYvalue" is not a valid method/property. But according to the API guide, there is a member called SortByYValue.

I hope somebody can give me a hint.

Thanks,

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

I looked closer into the API description...

SortByYValue is different from the rest of Sorting APIs - it belongs to IGraphProperties and not to ISourtCriteria. You can set it for the whole chart but not for an individual Dimension

Oleg

View solution in original post

4 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

SortByYValue might not be available for all charts. Try setting the sort order manually for your chart. If you can't set sort by Y Value manually, you won't be able to do it via macro.

Oleg

Not applicable
Author

Thanks for your reply. I can set it manually. It's an ordinary bar chart with one dimension and one calculated expression.

/Anders

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

I looked closer into the API description...

SortByYValue is different from the rest of Sorting APIs - it belongs to IGraphProperties and not to ISourtCriteria. You can set it for the whole chart but not for an individual Dimension

Oleg

Not applicable
Author

Thanks, Oleg!