How to Get Warned If an Appointment Is Scheduled in Non-working Hours in Your Outlook

To prevent accidentally scheduling an Outlook appointment in non-working hours, you can read this article. Here we will teach you how to let Outlook warn you if an appointment is scheduled in your non-working hours.

Many users want to block the non-working hours in their Outlook calendar. To be specific, they don’t accept any Outlook appointments or meetings scheduled in non-working hours. But, at times, they may accidentally create appointments out of working hours, or someone sends them meetings scheduled in non-working hours. Focusing on this issue, here we’ll show you a way to let Outlook warn you in such cases.

Get Warned If Appointment Is Scheduled in Non-working Hours

  1. To start with, launch your Outlook application.
  2. Then, press “Alt + F11” keys to access VBA editor.
  3. Next, put the following VBA code into the “ThisOutlookSession” project.
Public WithEvents objCalendar As Outlook.Folder
Public WithEvents objCalendarItems As Outlook.Items

Private Sub Application_Startup()
    Set objCalendar = Outlook.Application.Session.GetDefaultFolder(olFolderCalendar)
    Set objCalendarItems = objCalendar.Items
End Sub

Private Sub objCalendarItems_ItemAdd(ByVal Item As Object)
    Call GetWarnedIfInNonWorkingHours(Item)
End Sub

Sub GetWarnedIfInNonWorkingHours(ByVal objItem As Object)
    Dim objAppointment As Outlook.AppointmentItem
    Dim dStart, dEnd As Date
    Dim strMsg As String
    Dim nWarning As Integer
    Dim objPages As Outlook.Pages
    Dim objPage As Object
    Dim objControl As Object
    Set objAppointment = objItem
    dStart = Format(objAppointment.Start, "HH:MM")
    dEnd = Format(objAppointment.End, "HH:MM")
    'Change the working hours as per your case
    If (dStart < "9:00") Or (dEnd > "18:00") Then
       strMsg = objAppointment.Subject & " is scheduled in non-working hours. Do you want to change it?"
       nWarning = MsgBox(strMsg, vbQuestion + vbYesNo)
       If nWarning = vbYes Then
       End If
    End If
End Sub

VBA Code - Get Warned If Appointment Is Scheduled in Non-working Hours

  1. After that, restart your Outlook to activate this VBA project.
  2. Since then, every time when you create a new appointment within non-working hours, you will get a warning, like the following figure.Warning
  3. If you select “Yes” in the warning, the appointment will display. Now, you can modify its occurring time at will.Displayed Appointment

Block Outlook Data Loss

Are you persisting in making regular data backup for your Outlook? If not, you’d better take action at once. Outlook is admittedly vulnerable. In other words, PST data can be corrupt readily. In order to avoid losing your valuable Outlook data, it is necessary to back up PST on a regular basis. Plus, if affordable, you ought to get hold of a powerful Outlook fix tool, such as DataNumen Outlook Repair. It’ll come in handy when the inbox repair tool fails to fix your PST file.

Author Introduction:

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

Leave a Reply

Your email address will not be published. Required fields are marked *