1 Reply Latest reply: Jan 24, 2012 4:31 PM by Sally Hurley RSS

    Inconsistent results with SortByNumeric - it toggles ascending/descending

    Sally Hurley



      I have the following subroutine, that seemed to be working fine with v8.5, but now seems to be toggling instead of consistantly setting the sort in ascending order.  The subroutine is as follows


      SUB TableChartSortNumericAscending  (SheetName, ObjectName, ColumnNumber)


          ActiveDocument.GetApplication.WaitForIdle 3000


          ActiveDocument.Sheets(SheetName).SheetObjects(ObjectName).SortBy ColumnNumber

          ActiveDocument.GetApplication.WaitForIdle 3000


          set TableChart=ActiveDocument.GetSheetObject(ObjectName)

          set Prop = TableChart.GetProperties

          if TableChart.GetObjectType=4 then            'Its a Table

              Prop.Layout.ColLayouts.Item(ColumnNumber).SortCriteria.SortByNumeric = 1


              set vars = Prop.Dimensions

              vars.Item(ColumnNumber).SortCriteria.SortByNumeric = 1

          end if


          ActiveDocument.GetApplication.WaitForIdle 3000

          TableChart.SetProperties Prop

      END SUB


      It does pretty much as it says:  Sets a column in a table or chart to sort numerically in ascending order.  Well, it used to.  Now when I run it, if the column is currently set to ascending, after running the macro, it will be set to descending.  If it was set to discending before running the macro, it will then be set to ascending.


      I want this macro to *always* set the column to ascending, regardless what it's currently set to.


      What am I doing wrong?