How to Set the Default Start and End Time of All-day Events Based on Your Working Hours in Outlook

By default, you are not allowed to change the start and end time of all-day events as per your wishes in your Outlook. Now, this article will show you how to set the default start and end time of all-day events as per your working hours.

As you can see, when you enable the “All day event” option in an appointment, both the “Start Time” and “End Time” fields will be greyed out. In this scenario, it means that you aren’t permitted to change them to your liking. Therefore, in the followings, we will share you a method to set the default start and end time of all day events on basis of your working hours in your Outlook.

Set the Default Start and End Time of All-day Events Based on Your Working Hours in Outlook

Set the Default Start and End Time of All-day Events as per Working Hours

  1. To start with, launch your Outlook program.
  2. After you get into the main Outlook screen, you can press the “Alt + F11” key buttons.
  3. Subsequently, you will get access to the Outlook VBA editor window.
  4. In the current “Microsoft Visual Basic for Applications” window, you need to open the “ThisOutlookSession” project window.
  5. Then copy the following VBA code into this project.
Public WithEvents objInspectors As Outlook.Inspectors
Public WithEvents objAppointment As Outlook.AppointmentItem

Private Sub Application_Startup()
    Set objInspectors = Outlook.Application.Inspectors
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
    If Inspector.CurrentItem.Class = olAppointment Then
       Set objAppointment = Inspector.CurrentItem
    End If
End Sub

Private Sub objAppointment_PropertyChange(ByVal Name As String)
    Dim dOccuringDate As Date

    If Name = "AllDayEvent" Then
       If objAppointment.AllDayEvent = True Then
          dOccuringDate = Format(objAppointment.Start, "Short Date")
 
          'Change the Start and End Time as per Working Hours
          With objAppointment
               .AllDayEvent = False
               .Start = dOccuringDate & " 9:00:00 AM"
               .End = dOccuringDate & " 6:00:00 PM"
          End With
       End If
    End If
End Sub

Private Sub objAppointment_Open(Cancel As Boolean)
    If objAppointment.AllDayEvent = True Then
       dOccuringDate = Format(objAppointment.Start, "Short Date")
 
       With objAppointment
            .AllDayEvent = False
            .Start = dOccuringDate & " 9:00:00 AM"
            .End = dOccuringDate & " 6:00:00 PM"
       End With
    End If
End Sub

VBA Code - Set the Default Start and End Time of All-day Events Based on Your Working Hours

  1. After that, you need to sign this code. Click “Tools” > “Signature”.
  2. In the subsequent dialog box, follow onscreen instructions to assign a digital certificate to the new VBA project.
  3. Later you ought to change your Outlook macro settings to permit digitally signed macros.
  4. Eventually you can restart your Outlook application to activate this macro.
  5. From now on, every time you enable the “All day event” option in an Outlook appointment, the appointment’s start and end time will be changed to your working hours, like the following screenshot:Start Time and End Time Changed as per Working Hours

Retrieve Precious Data from Compromised Outlook file

Though Outlook boasts of multiple various features, it doesn’t mean that it is fully flawless. It still can get corrupted due to various factors, like email borne viruses, human improper handling and so on. Therefore, aside from making regular PST data backups, you’d better prepare a powerful external PST fix tool nearby, such as DataNumen Outlook Repair. It can repair PST issues in a short span of time.

Author Introduction:

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

Leave a Reply

Your email address will not be published.