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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to pass selected field value to variable in Marco ?

hi,

I know how to pass static text to variable in Marco,

f,g : ActiveDocument.Variables("variMonth").SetContent "Jan", true

but how to pass selected field value to variable in Marco ?

thanks in advance

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

There are mutiple solutions. Examples (assuming the field name is "Month"):
1. Create another variable vMonth in your application and define it as
=Motnh
Your macro will be
ActiveDocument.Variables("variMonth").SetContent ActiveDocument.Variables("vMotnh").GetContent.string, true
2. Copy directly from the field
set val=ActiveDocument.Fields("Month").GetSelectedValues
ActiveDocument.Variables("variMonth").SetContent val.item(0).text, true

In any case you have to make sure that only one value is selected in th field Month, or to test this condition in your macro and to do something if the condition is false.

View solution in original post

2 Replies
Anonymous
Not applicable
Author

There are mutiple solutions. Examples (assuming the field name is "Month"):
1. Create another variable vMonth in your application and define it as
=Motnh
Your macro will be
ActiveDocument.Variables("variMonth").SetContent ActiveDocument.Variables("vMotnh").GetContent.string, true
2. Copy directly from the field
set val=ActiveDocument.Fields("Month").GetSelectedValues
ActiveDocument.Variables("variMonth").SetContent val.item(0).text, true

In any case you have to make sure that only one value is selected in th field Month, or to test this condition in your macro and to do something if the condition is false.

Not applicable
Author

thanks Michael, it is working now