[Return to contents]
Last updated: before December, 1998
This is another version of the Named Find Event script submitted by Paul Bent. This time he has included a sort routine to sort the Named Finds.
Sub NewFindList Dim aFinds As Variant, intLB As Integer, intUB As Integer, aFStr() As String Dim intC1 As Integer, intC2 As Integer, intC3 As Integer, varTmp As Variant 'Get the named finds in the apr as an array of variants aFinds = CurrentDocument.NamedFindSorts 'Get the bounds of the array intLB = Lbound(aFinds) intUB = Ubound(aFinds) 'Loop through the array comparing each element with all higher elements 'If the lower element is greater than the higher element then switch them For intC1 = intLB To intUB - 1 For intC2 = intC1 + 1 To intUB If aFinds(intC1) > aFinds(intC2) Then varTmp = aFinds(intC1) aFinds(intC1) = aFinds(intC2) aFinds(intC2) = varTmp End If Next Next 'Now resize an array of strings. We need the finds as data type string 'to use the SetList method. Redim aFStr(intUB) 'Load the strings into the array For intC3 = 0 To intUB aFStr(intC3) = aFinds(intC3) Next 'Populate a dropdown box list with the string array. 'The dropdown box is named FList and is unbound. When I created it I 'had to type z as the first list item because an empty list is not allowed at creation. CurrentView.Body.FList.SetList(aFStr) End Sub