Thanks, that worked. The wrapper was easier than I thought.
I do have one item.
ON the killExp sub in ItemCB the following code is meant to retrieve the
explorer object to be removed from the Collection, then compare it against
the one you closed to see if they are same.
Public Sub KillExpl(ByRef anID As Short, ByRef objExplWrap As ExplWrap)
Dim objExplWrap2 As ExplWrap
objExplWrap2 = gcolExplWrap.Item(CStr(anID))
' checks to make sure we're removing the
' right Explorer from the collection
If Not objExplWrap2 Is objExplWrap Then
Err.Raise(1, Description:="Unexpected Error in KillExpl")
Exit Sub
End If
gcolExplWrap.Remove(CStr(anID))
End Sub
I changed mine to work with MailItems (MI) so the code looks like this.
Public Sub KillMI(ByRef anID As Short, ByRef objMIWrap As MIWrap)
Dim objMIWrap2 As MIWrap
objMIWrap2 = gcolMIWrap.Item(CStr(anID))
' checks to make sure we're removing the
' right MI from the collection
If Not objMIWrap2 Is objMIWrap Then
Err.Raise(1, Description:="Unexpected Error in KillExpl")
Exit Sub
End If
gcolMIWrap.Remove(CStr(anID))
End Sub
If I open two mailitems this is the collection I would have MI with key of
0 (MI0) and MI with key of 1 (MI1). I then close them in this order MI1
close MI0 close, it works fine. However if I close MI0 then MI1 the error
is raised. The reason is gColMIWrap.Item() selects the item not by key
value but by index value in the collection. So MI1 closing last errors
since the upper bound of the index for gColMIWrap is 0 because MI0 was
closed first and MI1 now has a collection index value of 0. The key value
is 1 and I am trying to select with that.
I anticipated gColMIWrap.Item() would select by Key value, but that doesn't
appear to be . Below is what I ended up doing. I changed the MIWrap Key
property to Public Property rather than Public WriteOnly so I could
reference it. I then use a for loop to check that the item in the
collection with the same key value as the item to be removed are the same,
and then remove it.
ItemCB, I believe, is compiled in VB6, which may explain the difference. Is
there a way to do this without the for loop. I don't mind the for loop,
since I am only capturing mailitems, but a more direct way would be nice.
Public Sub KillMI(ByRef anid As Short, ByRef objMIWrap As MIWrap)
Dim objMIWrap2 As MIWrap
Dim obj As MIWrap
For Each obj In gColMIWrap
If obj.Key = CStr(anid) Then
objMIWrap2 = obj
If Not objMIWrap2 Is objMIWrap Then
MsgBox("Error in KillMI of modMIWrap!")
Exit Sub
End If
gColMIWrap.Remove(CStr(anid))
Exit For
End If
Next
End Sub
,
Ken Slovak - said:
In NewInspector check the item type for the Inspector.CurrentItem.
Only add the item to the Inspector wrapper if it's the class you want.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
James Winton said:
I need to create a wrapper for mailitems. I have looked at the ItemsCB
example and understand enough to get started, but I'm not sure what I should
wrap.
I only care about mailitems. Can place the wrapper on mailitems, or would I
need to place it on all inspectors regardless of item type?
tia,
jw