Outlook 2007 - Calendar scheduling

mutts

New member
Local time
Today, 01:08
Joined
Dec 16, 2013
Messages
4
Hi,
This is my first post and I am sure I will be learning lots...
I am so close to getting a script for Outlook 2007. :banghead:
Basically, what I need is an alert popup for new and existing bookings, if the times are out of a selected range. By this I mean if a booking is say scheduled for before 8:00 a.m. and after 6:00 p.m. This is the script I am using, but it only works for new appointments and not for changes to existing appointments. Can someone please help me?
Thank you.

Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace
Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderCalendar).Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
On Error Resume Next
' change the start and end times as needed
If TimeValue(Item.Start) < TimeValue("7:59:00 AM") Or _
TimeValue(Item.End) > TimeValue("7:00:00 PM") Then
strMsg = "This appointment is scheduled to start at " & _
vbCrLf & TimeValue(Item.Start) & " and end at " & _
TimeValue(Item.End) & vbCrLf & _
"Do you still want to schedule it?"
intRes = MsgBox(strMsg, vbYesNo + vbExclamation, "Confirm Appointment Hours")
' If you say no, the opens for you to change the times or delete it.
If intRes = vbNo Then
Item.Display
End If
End If
End Sub
 
Last edited by a moderator:

Users who are viewing this thread

Back
Top Bottom