Excel VBA v VSTO Delete Outlook Appointment

I am trying to build a procedure in my Excel VB.net/VSTO add-in to delete an Outlook appointment.
I found the VBA code at the bottom and converted what I could but am not sure how to convert the following line:
"If oObject.Class = olAppointment Then"
I have marked the line with ???????

Public Sub DeleteAppointments(ByVal argSubject As String)

        Dim oApp As Microsoft.Office.Interop.Outlook.Application
        Dim oNameSpace As Microsoft.Office.Interop.Outlook.NameSpace
        Dim oApptItem As Microsoft.Office.Interop.Outlook.AppointmentItem
        Dim oFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
        Dim oMeetingoApptItem As Microsoft.Office.Interop.Outlook.MeetingItem
        Dim oObject As Object

        Dim sErrorMessage As String

        oApp = New Microsoft.Office.Interop.Outlook.Application

        System.Threading.Thread.Sleep(3000) 'a bit of startup grace time.

        On Error GoTo Err_Handler
        oNameSpace = oApp.GetNamespace("MAPI")
        oFolder = oNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar)

        For Each oObject In oFolder.Items
            If oObject.Class = ??????? Then
                oApptItem = oObject
                If InStr(oApptItem.Subject, argSubject) > 0 Then
                    oApptItem.Delete()
                End If
            End If
        Next oObject

        oApp = Nothing
        oNameSpace = Nothing
        oApptItem = Nothing
        oFolder = Nothing
        oObject = Nothing

        Exit Sub

Err_Handler:
        sErrorMessage = Err.Number & " " & Err.Description

    End Sub


Option Explicit
Option Compare Text
 
Public Sub Driver()
 Call DeleteAppointments("wibble")
End Sub
 
Public Sub DeleteAppointments(ByVal argSubject As String)
 
 Dim oApp As Outlook.Application
 Dim oNameSpace As Outlook.Namespace
 Dim oApptItem As Outlook.AppointmentItem
 Dim oFolder As Outlook.MAPIFolder
 Dim oMeetingoApptItem As Outlook.MeetingItem
 Dim oObject As Object
 Dim iUserReply As VbMsgBoxResult
 Dim sErrorMessage As String
 
 On Error Resume Next
 ' check if Outlook is running
 Set oApp = GetObject("Outlook.Application")
 If Err <> 0 Then
   'if not running, start it
   Set oApp = CreateObject("Outlook.Application")
 End If
 
 On Error GoTo Err_Handler
 Set oNameSpace = oApp.GetNamespace("MAPI")
 Set oFolder = oNameSpace.GetDefaultFolder(olFolderCalendar)
 
 For Each oObject In oFolder.Items
   If oObject.Class = olAppointment Then
     Set oApptItem = oObject
     If InStr(oApptItem.Subject, argSubject) > 0 Then
       iUserReply = MsgBox("Appointment found:-" & vbCrLf & vbCrLf _
            & Space(4) & "Date/time: " & Format(oApptItem.Start, "dd/mm/yyyy hh:nn") _
            & " (" & oApptItem.Duration & "mins)" & Space(10) & vbCrLf _
            & Space(4) & "Subject: " & oApptItem.Subject & Space(10) & vbCrLf _
            & Space(4) & "Location: " & oApptItem.Location & Space(10) & vbCrLf & vbCrLf _
            & "Delete this appointment?", vbYesNo + vbQuestion + vbDefaultButton2, "Delete Appointment?")
       If iUserReply = vbYes Then oApptItem.Delete
     End If
   End If
 Next oObject
 
 Set oApp = Nothing
 Set oNameSpace = Nothing
 Set oApptItem = Nothing
 Set oFolder = Nothing
 Set oObject = Nothing
 
 Exit Sub
 
Err_Handler:
 sErrorMessage = Err.Number & " " & Err.Description
 
End Sub
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieVBA ExpertCommented:
Do you need to convert it?

olAppointment is an Outlook constant, so if you have referenced the Outlook library it should be available.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks for the help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.