ItemRemove event don't fire when removing last item in items collection object 
Author Message
 ItemRemove event don't fire when removing last item in items collection object

Hi,

I have a problem with the ItemRemove event on the Items object collection.

The event ItemRemove does NOT fire when removing the last item in the
collection.

Here is the code:
'--------------------
Private WithEvents mOutlApp As Outlook.Application
Private mFolder                       As Outlook.MAPIFolder
Private WithEvents mItems      As Outlook.Items

Private Sub Command1_Click()
  Set mOutlApp = CreateObject("Outlook.Application")
  Set mFolder = mOutlApp.GetNamespace("MAPI").PickFolder
  Set mItems = mFolder.Items
End Sub

Private Sub mItems_ItemRemove()
  Debug.Print "Item Remove"
End Sub
'--------------------

/Christer



Mon, 23 Sep 2002 03:00:00 GMT  
 ItemRemove event don't fire when removing last item in items collection object
Known issue. Here is a possible workaround posted in the
microsoft.public.outlook.program_vba newsgroup:

Quote:


> > I had given a  thought for the workaround. But again the logic fails if
> I
> > press shift + delete key. The contact does not go in the deleted item
> > folder.

> > What I have implemented is a logic in the selection_change event. I had
> to
> > made a rigourous check for

> > a)  selection object is contact &
> > b) there is no item in the contact items ( since item_remove will fire
> > before selection_change when last item is deleted) &
> > c) folder is contacts folder

> > This And'ing condition will give me access of the item in the selection
> > object which has actually has already got removed in contacts
> collection. I
> > can thus retrieve it.

> > I guess I will have to do rigorous testing for the condition since
> > selection_change is the most common event. But i have implemented a
> couple
> > of flag checks and it works.

--
Sue Mosher
Author of
  "Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours"
  "Microsoft Outlook 2000 E-mail and Fax Guide"

Outlook and Exchange solutions at http://www.slipstick.com

- Show quoted text -

Quote:

> Hi,

> I have a problem with the ItemRemove event on the Items object collection.

> The event ItemRemove does NOT fire when removing the last item in the
> collection.

> Here is the code:
> '--------------------
> Private WithEvents mOutlApp As Outlook.Application
> Private mFolder                       As Outlook.MAPIFolder
> Private WithEvents mItems      As Outlook.Items

> Private Sub Command1_Click()
>   Set mOutlApp = CreateObject("Outlook.Application")
>   Set mFolder = mOutlApp.GetNamespace("MAPI").PickFolder
>   Set mItems = mFolder.Items
> End Sub

> Private Sub mItems_ItemRemove()
>   Debug.Print "Item Remove"
> End Sub
> '--------------------

> /Christer



Tue, 24 Sep 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ItemRemove event doesnot tell what item was removed

2. All items in my collection = the last item added

3. DataGrid, don't want the last row (new record), how to remove

4. add items and removing items from a list

5. Removing and item from a custom collection

6. DataGrid remove item error bind with own class inherit from collection

7. DataGrid remove item error bind with own class inherit from collection

8. Help removing items from collection,read issue.

9. Removing items from a collection

10. Problems removing items from collection by index

11. Removing a collection item problems ?

12. Removing a collection item problems ?

 

 
Powered by phpBB® Forum Software