Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a list box and I would like to store the selected value(s) is a variable.
I think I have worked out how to get the value from the list box - "ProdFamily" is my list box field.
set prodfamilyselection=ActiveDocument.Fields("ProdFamily").GetSelectedValuesHow do I store this in a variable?
Hi,
here you are
sub StoreValues
set v = ActiveDocument.Variables("sel")
set doc = ActiveDocument
set mySelections = doc.fields("SW_Temp").GetSelectedValues
sel = chr(39) & mySelections.Item(0).text & chr(39)
for i = 1 to mySelections.Count - 1
sel = sel & chr(44) & chr(39) & mySelections.Item(i).text &chr(39)
next
v.SetContent sel,true
end sub
A QV example follows in a few minutes.
Rainer
Hi,
here you are
sub StoreValues
set v = ActiveDocument.Variables("sel")
set doc = ActiveDocument
set mySelections = doc.fields("SW_Temp").GetSelectedValues
sel = chr(39) & mySelections.Item(0).text & chr(39)
for i = 1 to mySelections.Count - 1
sel = sel & chr(44) & chr(39) & mySelections.Item(i).text &chr(39)
next
v.SetContent sel,true
end sub
A QV example follows in a few minutes.
Rainer
Hi,
here are the application.
It´s not 100% perfect.
Rainer
Thanks Rainer - this is excellent and is exactly what I am looking for...
One quick question - in your example, how do you get the "sel" variable to update automatically when a list box selection is made?
Please remove the second macro.
Than the application runs without problems.
Rainer
Document Properties => Macros
See the screenshot.
Rainer
Thanks Rainer ... Your solution is exactly what I am looking for...
Thanks Rainer.... its really good one ...
Once again Thanks
I am using latest personal edition . I dont see macros Tab in Document properties. Could you help? Again my macros also dont recognize ActiveDocument Object