PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Finding Calendar items
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Finding Calendar items
![]() |
Finding Calendar items |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 ???? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 news 4F50857-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 ???? |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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 news 4F50857-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 ???? > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
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 news 4F50857-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 ???? >> |
|
|
|
#5 |
|
Guest
Posts: n/a
|
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 news 4F50857-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 ???? > >> > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

4F50857-2B57-4CFF-A8D3-A1FD9857DF3A@microsoft.com...
