Why can't I inherit Microsoft.Office.Interop.Outlook.AppointmentItem

Add-in Express™ Support Service
That's what is more important than anything else

Why can't I inherit Microsoft.Office.Interop.Outlook.AppointmentItem
 
add-in-express.com.forum




Posts: 50
Joined: 2010-10-17
This code:

Public Class clsAppointmentItem
Inherits Microsoft.Office.Interop.Outlook.AppointmentItem


End Class

Gives me 'Classes can only inherit from other classes'. But I though Microsoft.Office.Interop.Outlook.AppointmentItem was a class.

This works fine though:

Public Class clsAppointmentItem
Private WithEvents mAppointmentItem As Microsoft.Office.Interop.Outlook.AppointmentItem

Private Sub mAppointmentItem_Close(ByRef Cancel As Boolean) Handles mAppointmentItem.Close

End Sub
End Class


Sorry if I'm being dumb
Cheers
Posted 17 Oct, 2010 19:58:33 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hi Craig,

Microsoft.Office.Interop.Outlook.AppointmentItem is an interface, not a class.

I'd recommend that you intercept item-level events using the Outlook Item (not Items!) Events Class, see the Add New Item dialog of your add-in project; unlike the default implementation of the WithEvents operator in VB.NET, that class deals with all underlying COM details of carefully. In addition, the Item Events class is truly version-neutral: if your add-in is loaded in an older Outlook version, you just will not get events while the implementation in VB may fire an exception (if only I understand the things correctly). WithEvents produces one more problem: if a COM object is passed to your event handler then who is responsible for releasing it? I don't know the correct answer, sorry.


Andrei Smolin
Add-in Express Team Leader

PS. You may want to read http://www.add-in-express.com/creating-addins-blog/2008/10/30/releasing-office-objects-net/
Posted 18 Oct, 2010 09:41:59 Top