![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Some things just really bug me...this was one of them.
I wanted to be able to sort Birthdays and Holidays by the next time it occurs and Outlook just doesn't have a field for this. I'm not the only one who's bugged by this, and since I couldn't find code anywhere else on the web (but found lots of complaints), I thought I'd post my solution here. What this does is create a date field called "NextOccDate", looks to see if the date has already passed this year and if so, adds 1 to the year. You can drop this field from the user-defined fields into a table-view (I used Annual Events, since that shows me all the birthdays, etc.). This code assumes that you have categories called "Birthday/Anniversary" and "Holiday". You may need to change it appropriately, or take out that altogether. Since you need to manually run this if you add new events (or as the date changes), I figure I'll just call this whenever Outlook opens with the Auto_Open event. I don't have tons of items, so it takes seconds. You are then able to sort by this field and it sorts propertly, since it is defined as a date field. I need this because I recently took a cake decorating course and now for "practice", I need to make a cake any time I can. Most of my family/friends are SICK of cakes, but birthdays are a must. I need to see who my next victim is, so I can plan accordingly. LOL This little snippet needs to credit myriad people, groups, etc., not the least of which is Sue Mosher, who's site www.outlookcode.com is a must see for anyone trying to deal with Outlook programming (I'm officially an Access programmer). With a little adjustment, you should be able to just drop this into a module and run it. I hope this helps. Josetta ------ Sub SetNextOccurence() Dim myOlApp As New Outlook.Application Dim myNameSpace As Outlook.NameSpace Dim myFolder As Outlook.MAPIFolder Dim myItem As Outlook.AppointmentItem Dim myItems As Outlook.Items Set myNameSpace = myOlApp.GetNamespace("MAPI") Set myFolder = myNameSpace.GetDefaultFolder(olFolderCalendar) Set myItems = myFolder.Items For Each myItem In myItems If myItem.Categories = "Birthday/Anniversary" Or myItem.Categories = "Holiday" Then If DateSerial(Year(Date), Month(myItem.Start), Day(myItem.Start)) Date Then NextYear = Year(Now()) Else NextYear = Year(Now()) + 1 End If NextDate = DateSerial(NextYear, Month(myItem.Start), Day(myItem.Start)) Set prop = myItem.UserProperties.Add("NextOccDate", olDateTime) prop.Value = NextDate myItem.Save End If Next myItem End Sub |
Ads |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to undelete an appointment occurrence(s) in a series | B1 | Outlook - Calandaring | 1 | April 19th 06 07:52 PM |
Recurring appointment/events linked to other recurring appointment | uaewhitey | Outlook - Calandaring | 0 | February 2nd 06 08:55 PM |
outlook today recurring occurrence | AJ Meelan | Outlook - Calandaring | 3 | January 31st 06 05:08 PM |
How can I get a listing of each occurrence of a recurring event? | Bethany | Outlook - Calandaring | 1 | January 25th 06 02:39 PM |
Can I skip one occurrence of a recurring APPOINTMENT? | Sam | Outlook - Calandaring | 2 | January 23rd 06 03:40 PM |