Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

addDimension in Macro

Hello Experts,

I have a question for macro.

My customer is developing a macro like the followings. 

sub sortingEquipTrendChart(equips)
chartX = 639
chartY = 128
orignX = 0
orignY = chartY
flg = 0
objs = ActiveDocument.ActiveSheet.GetSheetObjects
for i=lbound(objs) to ubound(objs)
  if objs(i).GetObjectType = 12 then 
.
   dimen =  "=if(EQ_ID='" & equips(flg) & "',EQ_ID)"
   objs(i).RemoveDimension 0
   objs(i).RemoveDimension 0
   objs(i).AddDimension(dimen)   --> It doesn't work.
   objs(i).AddDimension("STS2_SEQ")  --> OK, It works fine.
   set pos = objs(i).GetRect
   if flg<>0 then
    orignY = orignY + (pos.Height - 1)
   end if
   pos.Top = orignY
   objs(i).SetRect pos
      set pos = nothing
      flg = flg + 1
  end if
next
end sub


But he want to know it is possible to use 'addDimension' with a parameter including expression like "=if(EQ_ID='" & equips(flg) & "',EQ_ID)".

Is it possible ?

Need your recommendation.

Thanks ,

WanKi,

15 Replies
pljsoftware
Creator III
Creator III

Can you post an example where I try to test your code?

Thanks

Luca Jonathan Panetta

Not applicable
Author

I asked for a sample to my customer.

If I get the one , yes I will post it.

Thank you,

WanKi,

Not applicable
Author

Marcus,


I tried to do that, but didn't work.

The equips() is the variable that is declared as an array.

So I printed the value of 'dimen' ( dimen =  "=if(EQ_ID='" & equips(flg) & "',EQ_ID)").

The result is the following. Maybe it's ok.

skhynix.png

But  the statement, objs(i).AddDimension(dimen), it doesn't work.

Regards,

WanKi,

marcus_sommer

You need it wrapped in double-quotes otherwise it would all content after the first single-quote interpret as comment.

- Marcus

pljsoftware
Creator III
Creator III

Hello Wanki,

yes is possible to use a variable to set you dimension.

Look this post http://community.qlik.com/message/30950#30950

The correct SUB is takeII()

Best regards

Luca Jonathan Panetta

Not applicable
Author

Luca Jonathan Panetta !!


WoW !! ^^

Thank you very much for your help.

WanKi,