3 Replies Latest reply: Jan 15, 2010 7:38 AM by belchema RSS

    MoveExpression Error, AddExpression


      Hi, im develop a macro that adding expressions in a table but i want keep the first but in the last position.

      I have this:


      Set Grafico=ActiveDocument.GetSheetObject("CH16")
      Set pGraf= Grafico.GetProperties
      Set Gexp= pGraf.Expressions

      Set Expresiones= ActiveDocument.Fields("DimensionesMercancias")

      if (Gexp.Count-1)>0 then Grafico.MoveExpression (Gexp.Count-1),0

      For x=0 to Gexp.Count-1
      Grafico.RemoveExpression 1
      Set NDimen = Expresiones.GetSelectedValues
      For i=0 to NDimen.Count -1
      If Dimension="Buque" then Nombre="LHNBU2"
      If Dimension="Mercancía" then Nombre="LHNMER2"
      If Dimension="Ope" then Nombre="LHOPE2"
      If Dimension="Puerto" then Nombre="LHNPO"
      If Dimension="País" then Nombre="LHNNO"
      If Dimension="Remit/Recep" then Nombre="LHNRR"
      If Dimension="Muelle" then Nombre="LHNMU"
      If Dimension="Envase" then Nombre="LHNENV"
      If Dimension="Consignatario" then Nombre="LHNCS2"
      Grafico.AddExpression Nombre
      Set pGraf= Grafico.GetProperties
      Set Gexpr= pGraf.Expressions
      Gexpr.Item(Gexpr.Count-1).Item(0).Data.ExpressionVisual.Label.v= Dimension
      Grafico.SetProperties pGraf
      Set pGraf= Grafico.GetProperties
      Set Gexp= pGraf.Expressions
      /*******************************My Error*************************************/
      if (Gexp.Count-1)>0 then Grafico.MoveExpression 0,(Gexp.Count-1)
      End Sub

      I dont know why dont work it, because i think that its simple, i want move the expression in position 0 to the last position, but i have an error. But if i write before "msgbox(Gexp.Count-1)" for see if its the good position, the macro works fine. I dont understand.


      Please, have someone any suggestion?


      Jose Manuel Abella


        • MoveExpression Error, AddExpression

          i know that the "MoveExpression" became useless since v8.50.6261 in the QlikView OCX

          fortunately, there is a workaround which is to remove all expressions before adding them again in the right order

            • MoveExpression Error, AddExpression

              Hi, Jgeorge i try your suggestion before and that works fine, but my problem about that is what i dont know how can i define an integer format for my expression? Because is a sum of Tons.

              How is the code for define a format (or property) like integer?


              Thanks for your time.

                • MoveExpression Error, AddExpression

                  Well i can solve my problem with the format, i found the code

                  i need add this



                  and all works.

                  I dont use the ExpressionMove, now i remove all expressions and in the last i add the expression that i want keep, like JGeorge tell.