A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - General Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Sort by Next Occurrence of Recurring Appointment for Birthdays



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 1st 06, 01:06 AM posted to microsoft.public.outlook
Josetta
external usenet poster
 
Posts: 4
Default Sort by Next Occurrence of Recurring Appointment for Birthdays

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 09:01 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.