How to Use Outlook VBA to Prevent Moving Appointment to an Incorrect Calendar Date by Mistake

Many users complain that they always drag and move appointments to another date by mistake. This article will look at this issue and offer you a quick method to prevent moving an appointment to an incorrect date  via Outlook VBA.

In Outlook, the default view for Calendar folders is “Calendar” view. In this view, you are permitted to move the appointments from the original date to another date simply via dragging. To be honest, it is indeed helpful in many cases. But it is inevitable that you may make some mistakes, such as moving an appointment by accident. After the false moving, if you forget its original occurring date, it will be quite difficult for you move it back to the original date correctly. Therefore, so as to prevent such a cumbersome case, you may hope that Outlook can auto display a reminder or warning when you move an appointment. Obviously, Outlook has no such a native feature. Thus, you need to seek other means. Here we will guide you how to get it with Outlook VBA.

Prevent Moving Appointment to an Incorrect Calendar Date by Mistake

Prevent Moving Appointments to an Incorrect Calendar Date by Mistake

  1. At the very outset, you should start your Outlook application properly.
  2. Then in the main Outlook window, switch to the “Developer” tab. If you can’t find it, you need to head to “File” > “Options” > “Customize Ribbon” to enable this tab firstly.
  3. Next under this tab, you can click on the “Visual Basic” button.
  4. Subsequently, you will get into the Outlook VBA editor window.
  5. Now you ought to open the “ThisOutlookSession” project window.
  6. After that, copy and paste the following VBA codes into it.
Private WithEvents objExplorer As Outlook.Explorer

Private Sub Application_Startup()
    Set objExplorer = Outlook.Application.ActiveExplorer
End Sub

Private Sub objExplorer_BeforeItemPaste(ClipboardContent As Variant, ByVal Target As MAPIFolder, Cancel As Boolean)
    Dim objCurrentFolder As Outlook.Folder
    Dim strPrompt As String
    Dim nResponse As Integer
    'Get the current folder
    Set objCurrentFolder = objExplorer.CurrentFolder
    'Check if the current folder is Calendar folder
    If objCurrentFolder.DefaultItemType = olAppointmentItem Then
       'Ask if to move the appointments
       strPrompt = "Are you sure to move the selected appointment?"
       nResponse = MsgBox(strPrompt, vbYesNo + vbQuestion, "Confirm Appointment Move")
       If nResponse = vbNo Then
          Cancel = True
       End If
    End If
End Sub

VBA Codes - Prevent Moving Appointment to an Incorrect Calendar Date

  1. And then you should digitally sign the new macro.
  • Firstly, use the inbuilt tool – Digital Certificates for VBA Projects, to create a digital certificate.
  • Then assign this certificate to the current macro.digitally sign the new macro
  1. Later you need to change your Outlook macro security level to low.
  2. After that, you can restart your Outlook to activate the macro.
  3. Eventually, you can have a try.
  • Open a calendar folder.
  • Then select an appointment and try to drag it to another date.drag an appointment to another date
  • At this point, you will receive a message asking if you ensure to move the appointment.message asking if you ensure to move the appointment
  • If you select “Yes”, the appointment will be moved successfully. If opt for “No”, nothing will happen.

Protect Your Valuable PST Data

If you attach great importance to your PST data in that it contains a great deal of client information, you have to endeavor to protect your PST file against damage. This will be a considerably difficult task as Outlook is error prone. Hence, first of all, you need to back up your PST files on a regular basis. In addition, keeping a robust PST repair tool, like DataNumen Outlook Repair, in vicinity is also a matter of necessity.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including mdf damage and outlook repair software products. For more information visit

Comments are closed.