Calendar looping through the current month?

S

Sydney

Hi All

From Word XP, I am successfully using this code that i found on the net.
It loops through the calendar items and warns when a particular subject is
found. The problem is, it searches the entire calendar going back 2 years.

Is it possible to get this to loop through the curent month or current week?
Thanks in advace

Sub GetAppt()

Dim olApp As Outlook.Application
Dim olNs As NameSpace
Dim olFldr As MAPIFolder
Dim olApt As AppointmentItem
Dim myDate As Date

myDate = Date ' test

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set olFldr = olNs.GetDefaultFolder(olFolderCalendar)


For Each olApt In olFldr.Items
If olApt.Subject = "test" Then
MsgBox "yes"
Debug.Print olApt.Subject, Format(olApt.Start, "mm/dd/yy")
End If

Next olApt

Set olApt = Nothing
Set olFldr = Nothing
Set olNs = Nothing
Set olApp = Nothing

End Sub
 
M

Michael Bauer

Am Wed, 8 Feb 2006 14:27:56 +1100 schrieb Sydney:


You can use the Restrict function to get a particular range.
 
S

Sue Mosher [MVP-Outlook]

See http://www.outlookcode.com/d/finddate.htm for examples of how to use it to return items in a date range.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top