Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Parameters in Macro

Morning,

I've this macro that do the same calculations with 2 diferents table object. The macro shuold be called from 2 Button Objects.

In order to identify wich button made the call (and that way knows wich table object take to do the calculations) I need to send by parameters a string with the name of the table to work at.

I tried to put in parenthesis the name of the table object at the button properties, but it doesn't work.

Which is the way to send a string parameter when I call a macro from a button object?? 'cause I dont want to have the macro twice just to change one line (the one with the name of the table to work)

Thxs in advance.

4 Replies
Not applicable
Author

Hi

I'm not sure if you can call a macro with parameters from the UI. I know it works in the script.
An alternative, if you use version 9, is to use a variable. Lets call it buttonClicked.
On you first button, you add an action to set the variable buttonClicked = button1. Then another action that runs your macro.
Do the same for the second button but set buttonClicked = button2.

Then, in your macro, you check the value of your variable:
set v = ActiveDocument.Variables("buttonClicked")
if v.GetContent.String = "button1" then
msgbox("Button1 clicked")
else
msgbox("Button2 clicked")
end if

/Fredrik


First action: External -> Set variable. Second action: External -> Run macro.

Not applicable
Author

If you create a global variable using 'Dim' you can set and use it in different subroutines.

Use globals sparingly:-)

Not applicable
Author

Hi Fredrik, thxs for your answer and idea.

I tried and that way, it works!

Thxs!

Not applicable
Author

Thanks Frederik, it works.