-
Re: Macro to select values in listbox
Parag Patil Jan 18, 2012 7:28 AM (in response to Dulce Sleeckx)Hi,
Use this code in ur macro..........
ActiveDocument.Fields("UNIT").Select "UNIT_VALUE"
Thanks & Regards,
Parag
-
Re: Macro to select values in listbox
Dulce Sleeckx Jan 18, 2012 7:54 AM (in response to Parag Patil )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
-
Macro to select values in listbox
Josh Duenyas Jan 18, 2012 12:49 PM (in response to Dulce Sleeckx)Try this:
set UnitSelected=ActiveDocument.Fields("UNIT").GetselectedValues
for i = 0 to val.Count-1
ActiveDocument.Fields("UNIT").Select UnitSelected.Item(i).Text
Next ibest regards
-
Re: Macro to select values in listbox
Dulce Sleeckx Jan 19, 2012 10:03 AM (in response to Josh Duenyas)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
-
Re: Macro to select values in listbox
Josh Duenyas Jan 19, 2012 12:43 PM (in response to Dulce Sleeckx)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
-
-
-
-
-
Re: Macro to select values in listbox
Rob Wunderlich Jan 20, 2012 2:16 AM (in response to Dulce Sleeckx)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
-
Macro to select values in listbox
Dulce Sleeckx Jan 20, 2012 2:11 AM (in response to Rob Wunderlich )Thanks Rob,
I didn't know what was going wrong here.
That fixed my problem.
Regards
Dulce
-
Re: Macro to select values in listbox
Javier Martinez Juanas Feb 18, 2014 5:24 AM (in response to Rob Wunderlich )Hi Rob,
how can i add another value to object returned by the function getSelectedValues?
Thanks
-
Re: Macro to select values in listbox
Renuka Mamidi Jul 10, 2014 12:55 PM (in response to Rob Wunderlich )Using SelectValues instead of select did not work for me.
-
-
Re: Macro to select values in listbox
Karthik Prabhu Jul 8, 2015 11:11 AM (in response to Dulce Sleeckx)Hi,
Can I put the ActiveDocument.Fields("UNIT").Select "UNIT_VALUE" right into my script editor? How to use this script.