Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Use of variables in macros

I have added a variable called "AverageOfCountry" using "Variable Overview>Add" from Layout. I defined the variable using an expression. How can I evaluate the expression linked to the variable and use it in a macro? I have to use it in a macro because I need the said variable's value on every sheet of the excel document I'm exporting to.

1 Solution

Accepted Solutions
OmarBenSalem

ActiveDocument.GetVariable("AverageOfCountry").getContent.string


and make sure ur variable begins with "=" when created

View solution in original post

9 Replies
marcus_sommer

Maybe with something like:

v = ActiveDocument.Variables("AverageOfCountry").GetContent.String

- Marcus

Clever_Anjos
Employee
Employee

this will retrieve your variable value

ActiveDocument.GetVariable("AverageOfCountry").GetContent.String

Anonymous
Not applicable
Author

Well it pastes me the expression string in the Excel table, not the value I would get by evaluating the expression. How do I get the variable expression to evaluate?

martinpohl
Partner - Master
Partner - Master

so set the variable with "=" in front of the expression that the value is calculated.

Regards

OmarBenSalem

ActiveDocument.GetVariable("AverageOfCountry").getContent.string


and make sure ur variable begins with "=" when created

Clever_Anjos
Employee
Employee

Use "=" at beginning of your variable

marcus_sommer

Another way might be to use evaluate() for the variable or maybe the expression itself - maybe like this: Re: How to export formula with Set analysis using macro

- Marcus

Anonymous
Not applicable
Author

that's it. Thank you!

dhasharadh
Creator III
Creator III

Dear all, 

i have a similar requirement, am using a macro to export my tables into txt format and want to keep prefix as current date to that generated txt files 

i used below F:\Document\$(vDate)_wang.txt  --- and it is getting named as it it, it is not picking the current date, Please help me. Thanks much