2 Replies Latest reply: Apr 18, 2012 4:29 PM by Peyman Azimabadi RSS

    Return value of RemoveExpression

    Peyman Azimabadi

      Hi all,

      i need to delete all Expressions of a chart in module. In API Guide, is documented that RemoveExpression returns the number of remaining Expressions in chart. I Use something like this:

       

      SET chart = ActiveDocument.GetSheetObject("CH01")

      n =  chart.RemoveExpression 0

       

      But this dosn't work. When i write the second line like bellow:

       

      chart.RemoveExpression 0

       

      modul runs without problem. But the number of remaining Expressions is very important for me.

      I will appreciate every idea.

       

      Regards

      Peyman

        • Return value of RemoveExpression
          Jose Tos

          I can´t assign the returns to a variable.

          If you want remove all expressions you must use chart.RemoveExpression all but I think you already know that.

           

          set chart = ActiveDocument.GetSheetObject("CH01")

          set cp = chart.GetProperties

          x = cp.Expressions.Item(0).Count

           

          You could count the number of expressions of each chart before remove all of them and use the sentence to remove all:

           

          chart.RemoveExpression all

           

          hope this helps,

           

          Chema


          • Re: Return value of RemoveExpression
            Peyman Azimabadi

            Thank you Chema,

            but "cp.Expressions.Item(0).Count" returns the number of subexpressions of first expression and "RemoveExpression all" is like "RemoveExpression 0". I think "all" is interprated as a variable with "0" value.

             

            i tryed many ways and finally found out that the code belows has the correct result:

             

            SET chart = ActiveDocument.GetSheetObject("CH01")

            SET cp    = chart.Getproperties

            exprCount = cp.Expressions.Count

             

            FOR i = 1 TO exprCount

                 chart.RemoveExpression 0

            NEXT