title: How to delete all appointments?
body: <p>I am trying to delete all appointments from an Excel VBA (Excel 2010) macro.</p>
  <p>I get an Error 13 (Type Mismatch) on <code>olFolder.Items.GetFirst</code>.</p>
  <p>It ran a few weeks ago.</p>
  <pre class="lang-vb prettyprint-override"><code>Sub DeleteAllAppointments()
  
  Dim olApp As Object
      
  Application.ScreenUpdating = False
  
  Set olApp = CreateObject(&quot;Outlook.Application&quot;)
  
  Dim olApptItem As Outlook.AppointmentItem
  Dim olMeetingItem As Outlook.MeetingItem
  
  Dim olNameSpace As Outlook.Namespace
  Dim olFolder As Outlook.MAPIFolder
  Dim olObject As Object
  Dim olItems As Items
  Dim i As Double
      
  Set olNameSpace = olApp.GetNamespace(&quot;MAPI&quot;)
  Set olFolder = olNameSpace.GetDefaultFolder(olFolderCalendar)
  Set olItems = olFolder.Items
     
  Set olApptItem = olFolder.Items.GetFirst
  
  For i = 1 To olItems.Count
      If olItems.Count &gt; 1 Then
          olApptItem.Delete
          Set olApptItem = olFolder.Items.GetNext
      Else
          Set olApptItem = olFolder.Items.GetLast
          olApptItem.Delete
      End If
  Next
     
  End Sub
  </code></pre>