Thanks for your answer Parag, but it's not what I was looking for.
My macro needs to select the value choosed by the user. But no matter what I try i keep getting the same error.
This is my last test, with no sucess sadly...
set UnitSelected = ActiveDocument.Fields("UNIT").GetSelectedValues
for i = 0 to UnitSelected.Count - 1
I am puzzled by what it is that you are trying to achieve and why it did not work for you.
ArrayListOfNames = Array("Name","Name",Name"...)
SelectInListBox "<ListBoxName>", ArrayListOfNames
List box name = MyListBox
ArrayListOfNames = Array("piskitta","jduenyas")
SelectInLisBox "MyListBox", ArrayOfNames
(Replace "Name" with your variables, replace <ListBoxName> with your list box name)
The names must already exit in the listbox in order to be "selected"
Alternately you can iterate through the array with a For...Next
I'm confused as to what you are trying to do. You are trying to make selections in the field "UNIT" that the user has already made selections in?
Re your type mismatch error. GetSelectedValues returns an IArrayOfFieldValue object. The function that reads IArrayOfFieldValue is SelectValues, not Select.
Set x = ActiveDocument.Fields("y").GetSelectedValues