Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get the value of the selected field while writing a Macro

Hi,

I am writhing a Macro.

How can I get the value of a selected field.

Also is there any documentation for writing a macro in Qlikview where I can find functions and Examples.

Regards

6 Replies
Not applicable
Author

If you install your QlikView Desktop with "Complete" option you will find the documentation under <Program Files>QlikView\Documentation

- APIGuide.qvw - will show you how you can access QV Objects in Macro

Also, the Help of QV Desktop might give you some guidance as well.

As to how to access the selected value/s, you can use ActiveDocument.Fields(<Field Name>).GetSelectedValues method. Please refer to API Guide for details.

I hope this helps.

Not applicable
Author

Thanks for your reply... The API guide is really helpful

However, I am struggling in implementing the GetSelectedValues Function.

Can you please give me an example.

Thanks.

Not applicable
Author

sub theFieldValues

set myfield = ActiveDocument.Fields("EmployeeName").GetPossibleValues

for each emps in myfield

msgbox(emps.String)

next

end sub

Not applicable
Author

Hello Shubhasheesh,

I tried running your code but it is throwing an error.

Can you please provide me with an alternative code.

Thanks.

Not applicable
Author

I got this correct:

sub theFieldValues

set v = ActiveDocument.Variables("a")

set myfield = ActiveDocument.Fields("MONTH_NUM").GetPossibleValues(1)

For i = 0 to myfield.Count-1

v.SetContent myfield.Item(i).text,true

next

end sub

Thanks



nicole
Contributor II
Contributor II

Try this:

sub theFieldValues ()

ActiveDocument.Fields("EmployeeName").Clear

set myfield = ActiveDocument.Fields("EmployeeName").GetPossibleValues

for i=0 to myfield.count-1

K = myfield.Item(i).Text

msgbox K

next

end sub

Nicole