How to Let Outlook Prompt for Target Calendar when Saving a New Appointment

Many users hope to gain more initiative in Outlook, such as being able to select a target calendar folder when creating and saving a new appointment. In this article, we will make this come true with VBA.

By default, when you create and intend to save an appointment, Outlook will auto save it to either the default calendar or the currently opened calendar. However, sometimes, maybe you would like to manually select a target calendar. Obviously, Outlook doesn’t provide such a feature. But you still can achieve it with VBA. Here we will show you the detailed code and steps.

Let Outlook Prompt for Target Calendar when Saving a New Appointment

Let Outlook Prompt for Target Calendar when Saving a New Appointment

  1. At the very beginning, launch your Outlook application.
  2. Then, in the Outlook main window, you need to press “Alt + F11” key buttons.
  3. Next, you will access the “Microsoft Visual Basic for Applications” window, in which you need to open the “ThisOutlookSession” project.
  4. Afterwards, you ought to copy the following VBA code into this project.
Public WithEvents objInspectors As Outlook.Inspectors
Public WithEvents objAppointment As Outlook.AppointmentItem
Public strDefaultCalendar, strCurrentFolder As String

Private Sub Application_Startup()
    Set objInspectors = Application.Inspectors
    strDefaultCalendar = Application.Session.GetDefaultFolder(olFolderCalendar).FolderPath
    strCurrentFolder = Application.ActiveExplorer.CurrentFolder.FolderPath
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
    If TypeOf Inspector.currentItem Is AppointmentItem Then
       Set objAppointment = Inspector.currentItem
    End If
End Sub

'Occurs when saving an appointment
Private Sub objAppointment_Write(Cancel As Boolean)
    Dim objTargetCalendar As Outlook.folder
 
    Cancel = True
 
    Set objTargetCalendar = Outlook.Application.Session.PickFolder
    If objTargetCalendar.DefaultItemType = olAppointmentItem Then
       If objTargetCalendar.FolderPath <> strDefaultCalendar And objTargetCalendar.FolderPath <> strCurrentFolder Then
          objAppointment.Move objTargetCalendar
       End If
    End If
End Sub

VBA Code - Let Outlook Prompt for Target Calendar when Saving a New Appointment

  1. Subsequently, you have to sign this code.
  2. Later, exit the VBA editor window and change your Outlook macro settings to permit macros.
  3. Finally, you could restart your Outlook to activate this VBA project.
  4. Now, you can take a shot:
  • First, create a new appointment by hitting “New Items” > “Appointment”.
  • Then, compose this appointment as usual.
  • Next, click the “Save & Close” button in the ribbon.
  • Immediately, the “Select Folder” dialog box will pop up, which demands you to choose a target calendar to save this appointment.
  • After you select a calendar folder and click “OK”.
  • The current appointment will be closed and saved to the selected target calendar.

Outlook Is Vulnerable to Various Dangerous Factors

Outlook is always preferred by multiple users due to a variety of functions. Yet, it doesn’t mean that Outlook is error prone. Virtually, Outlook has a serious flaw –It is vulnerable to many factors, including hardware or software issues, improper closing Outlook, virus infection, etc. Once Outlook is damaged, you’ll have to take aid of powerful external repair utility like DataNumen Outlook repair. It is well versed in recovering corrupt Outlook data.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including fix sql and outlook repair software products. For more information visit www.datanumen.com