Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Calendar looping through the current month? (http://www.outlookbanter.com/outlook-vba/7411-calendar-looping-through-current-month.html)

Sydney February 8th 06 03:27 AM

Calendar looping through the current month?
 
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



Michael Bauer February 8th 06 06:59 AM

Calendar looping through the current month?
 
Am Wed, 8 Feb 2006 14:27:56 +1100 schrieb Sydney:


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

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

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


Sue Mosher [MVP-Outlook] February 8th 06 01:21 PM

Calendar looping through the current month?
 
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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Michael Bauer" wrote in message ...
Am Wed, 8 Feb 2006 14:27:56 +1100 schrieb Sydney:


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

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

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



All times are GMT +1. The time now is 12:35 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-2006 OutlookBanter.com