/ Forums / Advansys Formativ / Creating Solutions with Formativ / Zombies: Undelete-able address book entries / Reply To: Zombies: Undelete-able address book entries

#6627
Support 1a
Participant

    You generally need to work backwards when deleting items from a collection. Starting from the beginning, the value of Count decreases after each delete, resulting in some items being left over.

    The following code should do what you want:

    Sub Main(Client, GWEvent)
    
         Dim objAddressBooks
         Dim objAddessBook
         Dim objAddressBookEntry
         Dim iCount
         Dim x
    
    
         ' Get the address books object
         Set objAddressBooks = GroupWise.Account.AddressBooks
    
    
         ' Locate the address book called "Test Account"
         Set objAddressBook = objAddressBooks.Item("Test Account")
    
         
          iCount = objAddressBook.AddressBookEntries.Count
         
         for x = iCount to 1 step -1
          set objAddressBookEntry = objAddressBook.AddressBookEntries.Item(x)
          objAddressBookEntry.Delete
         next
         
         
         Set objAddressBooks = nothing
    
      
    End Sub
    

    Advansys Support