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

Help

Hi

I wan to call a Parameterized Macro from button action

how can I do that?

4 Replies
alexandros17
Partner - Champion III
Partner - Champion III

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
Author

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

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
Partner - Champion III
Partner - Champion III

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