Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
i'm trying to select the values in a list box but i only get this message:
Type mismatch: 'ActiveDocument.Fields(...).Select'
My small macro only contains this code:
ActiveDocument.Fields("UNIT").Select ActiveDocument.Fields("UNIT").GetSelectedValues
Can someone help me, please?
Kind regards
Piskitta
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
ActiveDocument.Fields("z").SelectValues x
-Rob
Hi,
Use this code in ur macro..........
ActiveDocument.Fields("UNIT").Select "UNIT_VALUE"
Thanks & Regards,
Parag
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...
Sub SelectUnit
set UnitSelected = ActiveDocument.Fields("UNIT").GetSelectedValues
for i = 0 to UnitSelected.Count - 1
ActiveDocument.Fields("UNIT").Select(UnitSelected(i))
NEXT
End Sub
Best regards
Dulce
Try this:
set UnitSelected=ActiveDocument.Fields("UNIT").GetselectedValues
for i = 0 to val.Count-1
ActiveDocument.Fields("UNIT").Select UnitSelected.Item(i).Text
Next i
best regards
Hello,
thanks for the answer but mu problem keeps being the same.
I tried everything that i could find in the internet. But I had no luck.
Thanks,once again.
Kind regards
Dulce
I am puzzled by what it is that you are trying to achieve and why it did not work for you.
This works:
ArrayListOfNames = Array("Name","Name",Name"...)
SelectInListBox "<ListBoxName>", ArrayListOfNames
....
Example:
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
Best regards
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
ActiveDocument.Fields("z").SelectValues x
-Rob
Thanks Rob,
I didn't know what was going wrong here.
That fixed my problem.
Regards
Dulce
Hi Rob,
how can i add another value to object returned by the function getSelectedValues?
Thanks
Using SelectValues instead of select did not work for me.