J
JP Ronse
Hi All,
I just made the upgrade from Office 2003 to 2007 and, oh thanks to Bill, a
lot of VBA-code is not working anymore.
Let me first explain the context, I have an Exvel workbook containing all
teammembers with their daily schedule (they are working 24/24 -7/7). I build
some code in Excel to create tasks or meetingrequests to assign tasks to my
team.
The purpose of the meetingrequests is not that I want to see them but to
inform them that they have a special task to do or to follow up. Therefore,
I don't want to see it in my calendar. So, I created a second calendar and
move the appointment to this one, using the code below.
Since the upgrade, it is still working, but I can't send the meetingrequest
anymore. Any help will be very appreciated.
With kind regards,
JP
Public WithEvents myAppointments As Outlook.Items
Private Sub Application_Startup()
Set myAppointments =
Outlook.Session.GetDefaultFolder(olFolderCalendar).Items
End Sub
Private Sub myAppointments_ItemAdd(ByVal Item As Object)
Dim MyItem As AppointmentItem
Dim blnPlanning As Boolean
Dim strSubject As String
Dim intRecipients As Integer
Dim varEntryID As Variant
Dim fldPlanningCalendar As Outlook.MAPIFolder
Dim MyPlanningItem As String
'''Stop
strSubject = "*Resource Reservation*"
'''blnPlanning = False
Set MyItem = Item
MyItem.Recipients.ResolveAll
On Error GoTo Error_myPlanningAppointments
Set fldPlanningCalendar = Outlook.Session.Folders("Mailbox - Degroote
Jean-Pierre (TEB/MST)").Folders("Planning Calendar")
''' Planning Calendar exist
''' check item
If MyItem.Subject Like strSubject Then
blnPlanning = True
Else
blnPlanning = False
End If
'''MyItem.BusyStatus = olBusy
'''blnPlanning = True ''' means that meeting can be moved to planning
calendar
For intRecipients = 1 To MyItem.Recipients.Count
If MyItem.Recipients(intRecipients) Like "Jean-Pierre Degroote" Or
MyItem.Recipients(intRecipients) Like "Degroote Jean-Pierre*" Or
MyItem.Recipients(intRecipients) Like "DEGROOTE Jean-Pierre*" Then
blnPlanning = False
Exit For
End If
Next intRecipients
If MyItem.Recipients.Count = 0 Then blnPlanning = False
If blnPlanning = True Then
With MyItem
''''.ReminderSet = False
.ResponseRequested = False
.Move fldPlanningCalendar
.Close olDiscard
End With
End If
If blnPlanning = True Then
Set MyItem = fldPlanningCalendar.Items.GetLast
MyItem.Display
End If
Exit_myPlanningAppointments:
On Error GoTo 0
Exit Sub
Error_myPlanningAppointments:
Select Case Err.Number
Case -2147221233
If MyItem.Subject Like strSubject Then
'''For intRecipients = 1 To MyItem.Recipients.Count
''' If MyItem.Organizer =
MyItem.Recipients(intRecipients) Then
''' MyItem.BusyStatus = olBusy
''' Exit For
''' Else
''' MyItem.BusyStatus = olFree
''' Exit For
''' End If
'''Next intRecipients
blnPlanning = True
If blnPlanning = True Then
MyItem.BusyStatus = olFree
End If
End If
'''MyItem.Display
Set MyItem = Nothing
Resume Exit_myPlanningAppointments:
Case Else
MsgBox prompt:="An error occured.", Title:="Warning",
Buttons:=vbOKOnly
Resume Exit_myPlanningAppointments
End Select
End Sub
I just made the upgrade from Office 2003 to 2007 and, oh thanks to Bill, a
lot of VBA-code is not working anymore.
Let me first explain the context, I have an Exvel workbook containing all
teammembers with their daily schedule (they are working 24/24 -7/7). I build
some code in Excel to create tasks or meetingrequests to assign tasks to my
team.
The purpose of the meetingrequests is not that I want to see them but to
inform them that they have a special task to do or to follow up. Therefore,
I don't want to see it in my calendar. So, I created a second calendar and
move the appointment to this one, using the code below.
Since the upgrade, it is still working, but I can't send the meetingrequest
anymore. Any help will be very appreciated.
With kind regards,
JP
Public WithEvents myAppointments As Outlook.Items
Private Sub Application_Startup()
Set myAppointments =
Outlook.Session.GetDefaultFolder(olFolderCalendar).Items
End Sub
Private Sub myAppointments_ItemAdd(ByVal Item As Object)
Dim MyItem As AppointmentItem
Dim blnPlanning As Boolean
Dim strSubject As String
Dim intRecipients As Integer
Dim varEntryID As Variant
Dim fldPlanningCalendar As Outlook.MAPIFolder
Dim MyPlanningItem As String
'''Stop
strSubject = "*Resource Reservation*"
'''blnPlanning = False
Set MyItem = Item
MyItem.Recipients.ResolveAll
On Error GoTo Error_myPlanningAppointments
Set fldPlanningCalendar = Outlook.Session.Folders("Mailbox - Degroote
Jean-Pierre (TEB/MST)").Folders("Planning Calendar")
''' Planning Calendar exist
''' check item
If MyItem.Subject Like strSubject Then
blnPlanning = True
Else
blnPlanning = False
End If
'''MyItem.BusyStatus = olBusy
'''blnPlanning = True ''' means that meeting can be moved to planning
calendar
For intRecipients = 1 To MyItem.Recipients.Count
If MyItem.Recipients(intRecipients) Like "Jean-Pierre Degroote" Or
MyItem.Recipients(intRecipients) Like "Degroote Jean-Pierre*" Or
MyItem.Recipients(intRecipients) Like "DEGROOTE Jean-Pierre*" Then
blnPlanning = False
Exit For
End If
Next intRecipients
If MyItem.Recipients.Count = 0 Then blnPlanning = False
If blnPlanning = True Then
With MyItem
''''.ReminderSet = False
.ResponseRequested = False
.Move fldPlanningCalendar
.Close olDiscard
End With
End If
If blnPlanning = True Then
Set MyItem = fldPlanningCalendar.Items.GetLast
MyItem.Display
End If
Exit_myPlanningAppointments:
On Error GoTo 0
Exit Sub
Error_myPlanningAppointments:
Select Case Err.Number
Case -2147221233
If MyItem.Subject Like strSubject Then
'''For intRecipients = 1 To MyItem.Recipients.Count
''' If MyItem.Organizer =
MyItem.Recipients(intRecipients) Then
''' MyItem.BusyStatus = olBusy
''' Exit For
''' Else
''' MyItem.BusyStatus = olFree
''' Exit For
''' End If
'''Next intRecipients
blnPlanning = True
If blnPlanning = True Then
MyItem.BusyStatus = olFree
End If
End If
'''MyItem.Display
Set MyItem = Nothing
Resume Exit_myPlanningAppointments:
Case Else
MsgBox prompt:="An error occured.", Title:="Warning",
Buttons:=vbOKOnly
Resume Exit_myPlanningAppointments
End Select
End Sub