Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Help

Hi

I wan to call a Parameterized Macro from button action

how can I do that?

4 Replies
alexandros17
Not applicable

Re: Help

Ususally I define a variable in the document then I read that variable inside the macro and set the value of the variable in the button ...

Hopeit helps

Not applicable

Re: Help

Hi

Actually, I have created one Macro sub procedure with parameters in Macro

The parameters are ChartID and txt odject Id.

so, on button click  I want to pass that particular Chart ID and txt odject Id through parameters.

lets see 2 e.g.

1) e.g.

suppose I hv  1 sub 

sub xy(p1, p2)

......

.......

End sub

on button action , I wrote xy("a","b").

after, if click on button, it didnt perform any action.

but

2) e.g.

In macro If I call sub  xy("a","b") like

Sub Scall

xy("a","b")

End Sub

and if i wrote Scall Macro on button Action

then It works.., Perfect....

but I need to follow 1st scenario.

Gysbert_Wassenaar
Not applicable

Re: Help

You can add actions to a button. First add an action that sets the value of a variable. Next add an action that executes a macro. The macro will have to use the variable. You cannot directly pass a value to a macro, so that's why you need to use a variable.


talk is cheap, supply exceeds demand
alexandros17
Not applicable

Re: Help

Sub MYSUB
     set v = ActiveDocument.GetVariable("MyVar")

select case v.GetContent.String

case 1

v.SetContent "0",true

... do something else

case else

v.SetContent "1",true

... do something else             

end select

end sub 

This script read a variable MyVar defined in the document and you can set ithe variable with the button; there is no way to pass parameters in other way