Thank you for your support in still trying to help me. The macro security settings are set to “Warning for all macros” by default and this cannot be changed. There are no error messages received with any scripts including the latest script. I found the original script and tested it again and it works fine ONLY for new invitations and not for revised invitations. So here below is what I currently have which works for new invitations, which is followed by the latest script which does not work for new or existing invitations. Can you please see where the fix is needed and send me the corrected script.
Thank you again.
Script that works for NEW invitations
|
Private WithEvents Items As Outlook.Items
Public Sub Initialize_handler()
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("6:59:00 AM") Or _
TimeValue(Item.End) > TimeValue("4:59: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
Script that does not work for new or existing invitations
Public Sub Initialize_handler()
Dim Ns As Outlook.NameSpace
Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderCalendar).Items
End Sub
Private Sub Items_ItemChange(ByVal Item As Object)
On Error Resume Next
' change the start and end times as needed
If TimeValue(Item.Start) < TimeValue("6:59:00 AM") Or _
TimeValue(Item.End) > TimeValue("4:59: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