Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
How to pass the argument to the function (Macro)?
If I understand your question correctly, please see the attached QV example.
Thanks Upendra, but it will not resolved my issue. I want to pass the argument while calling macro function using button.
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.
Thanks Deepak,
Can u share any example with me?
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
Hi Manesh,
PFA
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.
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.