I've written a routine for our staff to book their holidays, part of which is to place an all-day appointment in their Outlook personal calendar.
There is also the facility to cancel holidays booked, part of which is to delete the entry in the personal calendar, using the Remove method.
It is this last step that doesn't quite work -
When you view the calendar within Outlook, the entry isn't there and using automation doesn't find the item either. However, if you go to book a meeting on that date, it shows up when you click the "Attendee availability" tab.
Here is the code for opening Outlook:
This is my original code using the Remove method:
I tried the Delete method...
...which worked perfectly when I stepped through the code in the Debugger. However when I let the code run, it fails on the Delete line saying "parameter is not optional"
Has anyone else come across this problem? Did you find a solution?
Thanks,
Stewart
There is also the facility to cancel holidays booked, part of which is to delete the entry in the personal calendar, using the Remove method.
It is this last step that doesn't quite work -
When you view the calendar within Outlook, the entry isn't there and using automation doesn't find the item either. However, if you go to book a meeting on that date, it shows up when you click the "Attendee availability" tab.
Here is the code for opening Outlook:
Code:
oOut = CREATEOBJECT("Outlook.application")
oMapi = oOut.GetNamespace("MAPI")
oPCal = oMapi.GetDefaultFolder(9)
oItems = oPCal.Items
Code:
Itemcount = 0
FOR EACH oItem IN oItems
ItemCount = ItemCount + 1
IF oItem.Subject = [STEWART C-holiday] AND TTOD(oItem.Start) = ForDate
oItems.Remove(ItemCount)
EXIT
ENDIF
ENDFOR
Code:
FOR EACH oItem IN oItems
IF oitem.subject=[STEWART C-holiday] AND TTOD(oItem.Start) = ForDate
oitem.Delete
EXIT
ENDIF
ENDFOR
Has anyone else come across this problem? Did you find a solution?
Thanks,
Stewart