PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Finding Calendar items

Reply

Finding Calendar items

 
Thread Tools Rate Thread
Old 09-03-2006, 10:34 PM   #1
=?Utf-8?B?QW5keQ==?=
Guest
 
Posts: n/a
Default Finding Calendar items


Sorry to place this in 2 places on Access Groups but wasn't sure which SME
areas to place question.

I am trying to locate an item in Outlook Calendar folder using Access VBA.
I know the subject and the date of the appointment and that it is an All Day
Day Event. Can anyone help with the code ?

Something like :-

Dim olApp As Outlook.Application
Dim objCalendar As Object
Dim objAppointment As Object
Dim CalEntryID As Variant
Dim SQLcmd As String
Dim StaffID As Variant
Dim olNS As NameSpace
Dim olFolder As MAPIFolder
Dim olDataFolder As MAPIFolder
Dim olItem As AppointmentItem
Dim FDO as Variant

Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI") ' open the MAPI Namespace

Set olFolder = olNS.GetDefaultFolder(olFolderCalendar)

FDO = Format(09/03/2006, "dd/mm/yyyy")

Set objAppointment = olFolder.Items.Find(Start = FDO AND Subject = "Long
Meeting" AND AllDayEvent = Yes)

or similar ????
  Reply With Quote
Old 10-03-2006, 02:32 AM   #2
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: Finding Calendar items

You're close. You need quotes around your date string. See http://www.outlookcode.com/d/finddate.htm.

Also, the valid values for Boolean fields are True and False, not Yes and No.

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


"Andy" <Andy@discussions.microsoft.com> wrote in message news4F50857-2B57-4CFF-A8D3-A1FD9857DF3A@microsoft.com...
> Sorry to place this in 2 places on Access Groups but wasn't sure which SME
> areas to place question.
>
> I am trying to locate an item in Outlook Calendar folder using Access VBA.
> I know the subject and the date of the appointment and that it is an All Day
> Day Event. Can anyone help with the code ?
>
> Something like :-
>
> Dim olApp As Outlook.Application
> Dim objCalendar As Object
> Dim objAppointment As Object
> Dim CalEntryID As Variant
> Dim SQLcmd As String
> Dim StaffID As Variant
> Dim olNS As NameSpace
> Dim olFolder As MAPIFolder
> Dim olDataFolder As MAPIFolder
> Dim olItem As AppointmentItem
> Dim FDO as Variant
>
> Set olApp = New Outlook.Application
> Set olNS = olApp.GetNamespace("MAPI") ' open the MAPI Namespace
>
> Set olFolder = olNS.GetDefaultFolder(olFolderCalendar)
>
> FDO = Format(09/03/2006, "dd/mm/yyyy")
>
> Set objAppointment = olFolder.Items.Find(Start = FDO AND Subject = "Long
> Meeting" AND AllDayEvent = Yes)
>
> or similar ????

  Reply With Quote
Old 10-03-2006, 03:28 PM   #3
=?Utf-8?B?QW5keQ==?=
Guest
 
Posts: n/a
Default Re: Finding Calendar items

Thanks Sue - If my Search returns nothing in the line :-

Set objAppointment = olFolder.Items.Find(strFind) then I get the error :-

"object variable or with block variable not set" (I am calling from Access
97).

How do I deal with setting the objAppointment when the search returns no
items?

Thanks.

------

"Sue Mosher [MVP-Outlook]" wrote:

> You're close. You need quotes around your date string. See http://www.outlookcode.com/d/finddate.htm.
>
> Also, the valid values for Boolean fields are True and False, not Yes and No.
>
> --
> 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
>
>
> "Andy" <Andy@discussions.microsoft.com> wrote in message news4F50857-2B57-4CFF-A8D3-A1FD9857DF3A@microsoft.com...
> > Sorry to place this in 2 places on Access Groups but wasn't sure which SME
> > areas to place question.
> >
> > I am trying to locate an item in Outlook Calendar folder using Access VBA.
> > I know the subject and the date of the appointment and that it is an All Day
> > Day Event. Can anyone help with the code ?
> >
> > Something like :-
> >
> > Dim olApp As Outlook.Application
> > Dim objCalendar As Object
> > Dim objAppointment As Object
> > Dim CalEntryID As Variant
> > Dim SQLcmd As String
> > Dim StaffID As Variant
> > Dim olNS As NameSpace
> > Dim olFolder As MAPIFolder
> > Dim olDataFolder As MAPIFolder
> > Dim olItem As AppointmentItem
> > Dim FDO as Variant
> >
> > Set olApp = New Outlook.Application
> > Set olNS = olApp.GetNamespace("MAPI") ' open the MAPI Namespace
> >
> > Set olFolder = olNS.GetDefaultFolder(olFolderCalendar)
> >
> > FDO = Format(09/03/2006, "dd/mm/yyyy")
> >
> > Set objAppointment = olFolder.Items.Find(Start = FDO AND Subject = "Long
> > Meeting" AND AllDayEvent = Yes)
> >
> > or similar ????

>

  Reply With Quote
Old 10-03-2006, 03:41 PM   #4
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: Finding Calendar items

If the search returns no items, it means that either there are no items matching your conditions or the search query string doesn't accurately reflect the conditions you want to look for. When using Find, you always need to check whether you actually got an item:

On Error Resume Next
MsgBox strFind
Set objAppointment = olFolder.Items.Find(strFind)
If Not objAppointment Is Nothing Then
' it's safe to work with objAppointment, e.g.:
MsgBox objAppointment.Subject
End If

I strongly recommend using the first MsgBox statement above as you're developing the code. It's likely to show you any major problems with the search query rather fast.
--
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


"Andy" <Andy@discussions.microsoft.com> wrote in message news:AF8A42A9-32E7-4BCA-92AE-3E8FB40FBB62@microsoft.com...
> Thanks Sue - If my Search returns nothing in the line :-
>
> Set objAppointment = olFolder.Items.Find(strFind) then I get the error :-
>
> "object variable or with block variable not set" (I am calling from Access
> 97).
>
> How do I deal with setting the objAppointment when the search returns no
> items?
>
> Thanks.
>
> ------
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> You're close. You need quotes around your date string. See http://www.outlookcode.com/d/finddate.htm.
>>
>> Also, the valid values for Boolean fields are True and False, not Yes and No.


>>
>> "Andy" <Andy@discussions.microsoft.com> wrote in message news4F50857-2B57-4CFF-A8D3-A1FD9857DF3A@microsoft.com...
>> > Sorry to place this in 2 places on Access Groups but wasn't sure which SME
>> > areas to place question.
>> >
>> > I am trying to locate an item in Outlook Calendar folder using Access VBA.
>> > I know the subject and the date of the appointment and that it is an All Day
>> > Day Event. Can anyone help with the code ?
>> >
>> > Something like :-
>> >
>> > Dim olApp As Outlook.Application
>> > Dim objCalendar As Object
>> > Dim objAppointment As Object
>> > Dim CalEntryID As Variant
>> > Dim SQLcmd As String
>> > Dim StaffID As Variant
>> > Dim olNS As NameSpace
>> > Dim olFolder As MAPIFolder
>> > Dim olDataFolder As MAPIFolder
>> > Dim olItem As AppointmentItem
>> > Dim FDO as Variant
>> >
>> > Set olApp = New Outlook.Application
>> > Set olNS = olApp.GetNamespace("MAPI") ' open the MAPI Namespace
>> >
>> > Set olFolder = olNS.GetDefaultFolder(olFolderCalendar)
>> >
>> > FDO = Format(09/03/2006, "dd/mm/yyyy")
>> >
>> > Set objAppointment = olFolder.Items.Find(Start = FDO AND Subject = "Long
>> > Meeting" AND AllDayEvent = Yes)
>> >
>> > or similar ????

>>

  Reply With Quote
Old 10-03-2006, 04:35 PM   #5
=?Utf-8?B?QW5keQ==?=
Guest
 
Posts: n/a
Default Re: Finding Calendar items

Great, all works now - Thanks.
----
"Sue Mosher [MVP-Outlook]" wrote:

> If the search returns no items, it means that either there are no items matching your conditions or the search query string doesn't accurately reflect the conditions you want to look for. When using Find, you always need to check whether you actually got an item:
>
> On Error Resume Next
> MsgBox strFind
> Set objAppointment = olFolder.Items.Find(strFind)
> If Not objAppointment Is Nothing Then
> ' it's safe to work with objAppointment, e.g.:
> MsgBox objAppointment.Subject
> End If
>
> I strongly recommend using the first MsgBox statement above as you're developing the code. It's likely to show you any major problems with the search query rather fast.
> --
> 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
>
>
> "Andy" <Andy@discussions.microsoft.com> wrote in message news:AF8A42A9-32E7-4BCA-92AE-3E8FB40FBB62@microsoft.com...
> > Thanks Sue - If my Search returns nothing in the line :-
> >
> > Set objAppointment = olFolder.Items.Find(strFind) then I get the error :-
> >
> > "object variable or with block variable not set" (I am calling from Access
> > 97).
> >
> > How do I deal with setting the objAppointment when the search returns no
> > items?
> >
> > Thanks.
> >
> > ------
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> >> You're close. You need quotes around your date string. See http://www.outlookcode.com/d/finddate.htm.
> >>
> >> Also, the valid values for Boolean fields are True and False, not Yes and No.

>
> >>
> >> "Andy" <Andy@discussions.microsoft.com> wrote in message news4F50857-2B57-4CFF-A8D3-A1FD9857DF3A@microsoft.com...
> >> > Sorry to place this in 2 places on Access Groups but wasn't sure which SME
> >> > areas to place question.
> >> >
> >> > I am trying to locate an item in Outlook Calendar folder using Access VBA.
> >> > I know the subject and the date of the appointment and that it is an All Day
> >> > Day Event. Can anyone help with the code ?
> >> >
> >> > Something like :-
> >> >
> >> > Dim olApp As Outlook.Application
> >> > Dim objCalendar As Object
> >> > Dim objAppointment As Object
> >> > Dim CalEntryID As Variant
> >> > Dim SQLcmd As String
> >> > Dim StaffID As Variant
> >> > Dim olNS As NameSpace
> >> > Dim olFolder As MAPIFolder
> >> > Dim olDataFolder As MAPIFolder
> >> > Dim olItem As AppointmentItem
> >> > Dim FDO as Variant
> >> >
> >> > Set olApp = New Outlook.Application
> >> > Set olNS = olApp.GetNamespace("MAPI") ' open the MAPI Namespace
> >> >
> >> > Set olFolder = olNS.GetDefaultFolder(olFolderCalendar)
> >> >
> >> > FDO = Format(09/03/2006, "dd/mm/yyyy")
> >> >
> >> > Set objAppointment = olFolder.Items.Find(Start = FDO AND Subject = "Long
> >> > Meeting" AND AllDayEvent = Yes)
> >> >
> >> > or similar ????
> >>

>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

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