Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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
Next
Set NDimen = Expresiones.GetSelectedValues
For i=0 to NDimen.Count -1
Dimension=NDimen.Item(i).Text
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
Next
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

1 Solution

Accepted Solutions
Not applicable
Author

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

View solution in original post

3 Replies
Not applicable
Author

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

Not applicable
Author

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.

Not applicable
Author

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

i need add this


Gexpr.Item(Gexpr.Count-1).Item(0).Data.ExpressionVisual.NumberPresentation.Type=10
Gexpr.Item(Gexpr.Count-1).Item(0).Data.ExpressionVisual.NumberPresentation.Fmt="#.##0"



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.

Thanks