Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
maneshkhottcpl
Partner - Creator III
Partner - Creator III

Passing argument to macro Function .

Hi All,

How to pass the argument to the function (Macro)?

8 Replies
vupen
Partner - Creator
Partner - Creator

If I understand your question correctly, please see the attached QV example.

maneshkhottcpl
Partner - Creator III
Partner - Creator III
Author

Thanks Upendra, but it will not resolved my issue. I want to pass the argument while calling macro function using button.

deepakk
Partner - Specialist III
Partner - Specialist III

hi Manesh,

Before calling the macro Function , you can set a variable value and then call a macro code.

And in the initial code of the macro you can retrieve the variable data and used it in your functions.

maneshkhottcpl
Partner - Creator III
Partner - Creator III
Author

Thanks Deepak,

Can u share any example with me?

amars
Specialist
Specialist

hi Mnesh,

U can write a function like this

function getVariable(varName)

set v = ActiveDocument.Variables(varName)

getVariable = v.GetContent.String

end function



& use it like

strSubject = getvariable("mailSubject")

The above way uses Function with a variable or the other direct way is to use ActiveDocument.GetVariable

set MgrName = ActiveDocument.GetVariable("vMgrID")

Also to Set a Variable u can use a macro like

set MgrID = ActiveDocument.GetVariable("vMgrID")

MgrID.SetContent "00000002" ,true





deepakk
Partner - Specialist III
Partner - Specialist III

Hi Manesh,

PFA

maneshkhottcpl
Partner - Creator III
Partner - Creator III
Author

HI deepak,

I think i am not explaining u properly.

Ok

I want to create a function say

function display(StrShID) ' StrShID as argument

msgbox StrShID

end function

then in button click i call the function

i.e display('SHO1') '' SHO1 is sheet name to pass the argument to function

so whenever i clik on button , it will call the macro with argument.

deepakk
Partner - Specialist III
Partner - Specialist III

hi Manesh,

How dynamic is your data from the button. Will the value will come from user selection....

The above same can be acheived in the same way.,,,

IN the variable vtest store CH01. and in the function get the Variable and use it in the function.

same as what i had done in the above application.

If you can attach an application, I wil try to implement on that and Show it to u.