The list box is the most basic sheet object. It contains a list of all possible values of a specific field. Each row in the list box can represent several records in the loaded table, all with identical values. Selecting one value may thus be equivalent to selecting several records in the loaded table.
Here we are automating the selection by each line through the macro in button action. This selects each line from Bottom to top.
Macro:
Sub SelectNext
set mySelections = ActiveDocument.fields(“Id”).GetSelectedValues(1)
ActiveDocument.Fields(“Id”).Clear
set vPosVal = ActiveDocument.fields(“Id”).GetPossibleValues
if mySelections.Count = 0 then
set val=ActiveDocument.Fields(“Id”).GetPossibleValues(vPosVal.count)
ValueToSelect = val.Item(val.Count-1).Text
else
set val=ActiveDocument.Fields(“Id”).GetPossibleValues
IamDone = ” ”
for i=0 to val.Count-1
ValueToSelect = val.Item(val.Count-1-i).Text
if IamDone = “X” then
exit for
end if
if val.Item(val.Count-1-i).Text = mySelections.Item(0).text then
IamDone = “X”
end if
next
end if
ActiveDocument.Fields(“Id”).Select ValueToSelect
End Sub
No Comments