Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I would like to create a macro which is triggered when a variable is changed through an inputbox. Therefore I have created the following simple macro.
Sub SwitchFieldSelection
set vVariable = ActiveDocument.Variables("v_Switch")
IF vVariable.GetContent.String = "Yes" THEN
set objField = ActiveDocument.Fields("Type")
set objFieldValues = objField.GetNoValues
objField.Unlock
objFieldValues.Add
objFieldValues.Add
objFieldValues(0).Text = "Type1"
objFieldValues(0).IsNumeric = false
objFieldValues(1).Text = "Type"
objFieldValues(1).IsNumeric = false
objField.SelectValues objFieldValues
objField.Lock
ELSE
set objField = ActiveDocument.Fields("Type")
objField.Unlock
objField.Clear
objField.Lock
END IF
End Sub
The problem is that only the second value is selected in the field, so in this case 'Type2'
Am I doing something wrong or is it simply not possible this way?
Regards
EDIT: Found the solution, was just a simple typo in the value which in want to select. So this is solved.
Maybe you can use the toggleselect function.
I used it and it works for me:
Here is an example of what I used:
sub NameSub
set FIELDNAME = activedocument.fields("FIELDNAME")
FIELDNAME.select "20200" ' clears all in FIELDNAME and selects 20200
FIELDNAME.toggleselect "50300" ' selects 50300
FIELDNAME.toggleselect "60200" ' selects 60200
end sub
See my response closer to the end of this: http://community.qlik.com/forums/t/43234.aspx
Very simple macro, also with toggleselect, as from Dennis.