finding appointment

E

Esperanza

Hello VBA Expert
I need to find an appointment in Outlook to update it.
My appointment is set to all day event.

If I used the following code, it cannot find the appointment. oApptItem will
equal nothing

Set oApptItem = oCalendarFolder.Items.Find("[subject] = " & strActivite & "
AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """" & "
AND [AlldayEvent]= true")



But if my appointment is NOT set to all day event the folloying code works :

' Set oApptItem = oCalendarFolder.Items.Find("[subject] = " &
strActivite & " AND [Location]=" & strLocation & " AND [Start] = """ &
tdystart & """")


How can I find my appointments set to all day event?

Thanks for your help !!
Esperanza
 
K

Ken Slovak - [MVP - Outlook]

Does it work if that clause is written like this:

Set oApptItem = oCalendarFolder.Items.Find("[subject] = " &
strActivite & "
AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """"
& "
AND [AllDayEvent]= " & True)


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
 
E

Esperanza

Unfortunately no,
but I tried the following after unchecking the AllDayEvent :
Set oApptItem = oCalendarFolder.Items.Find("[subject] = " & strActivite & "
AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """")

and it could find it !!

I tried also the following after unchecking the AllDayEvent :

'Set oApptItem = oCalendarFolder.Items.Find("[subject] = " & strActivite &
" AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """" & "
AND [AllDayEvent]= " & False)
and it couldn't find it .

Unfortunately for me, all my appointments are checked AllDayEvent and my
program has to find them.

Must be someone who had the same problem.
Esperanza


Ken Slovak - said:
Does it work if that clause is written like this:

Set oApptItem = oCalendarFolder.Items.Find("[subject] = " &
strActivite & "
AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """"
& "
AND [AllDayEvent]= " & True)


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Esperanza said:
Hello VBA Expert
I need to find an appointment in Outlook to update it.
My appointment is set to all day event.

If I used the following code, it cannot find the appointment. oApptItem will
equal nothing

Set oApptItem = oCalendarFolder.Items.Find("[subject] = " & strActivite & "
AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """" & "
AND [AlldayEvent]= true")



But if my appointment is NOT set to all day event the folloying code works :

' Set oApptItem = oCalendarFolder.Items.Find("[subject] = " &
strActivite & " AND [Location]=" & strLocation & " AND [Start] = """ &
tdystart & """")


How can I find my appointments set to all day event?

Thanks for your help !!
Esperanza
 
E

Esperanza

I tried your code and I still got the same problem. the program cannot find
anything if the appointment is set to AllDayEvent. The last line of code,
I'am sending you works if the appointment is NOT set to AllDayEvent, if it
is, then, the program cannot find it.
I have been working on this problem for weeks,
there must be someone who experienced the same problem.
Esperanza


Set oApptItem = oCalendarFolder.Items.Find("[subject] = " & strActivite & "
AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """" & "
AND [AllDayEvent]= true")

Set oApptItem = oCalendarFolder.Items.Find("[subject] = " & strActivite &
" AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """" & "
AND [AllDayEvent]= " & True)


Set oApptItem = oCalendarFolder.Items.Find("[subject] = " & strActivite
& " AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """" &
" AND [AllDayEvent]= ""True""")

Set oApptItem = oCalendarFolder.Items.Find("[subject] = " & strActivite &
" AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """")




Ken Slovak - said:
Does it work if that clause is written like this:

Set oApptItem = oCalendarFolder.Items.Find("[subject] = " &
strActivite & "
AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """"
& "
AND [AllDayEvent]= " & True)


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Esperanza said:
Hello VBA Expert
I need to find an appointment in Outlook to update it.
My appointment is set to all day event.

If I used the following code, it cannot find the appointment. oApptItem will
equal nothing

Set oApptItem = oCalendarFolder.Items.Find("[subject] = " & strActivite & "
AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """" & "
AND [AlldayEvent]= true")



But if my appointment is NOT set to all day event the folloying code works :

' Set oApptItem = oCalendarFolder.Items.Find("[subject] = " &
strActivite & " AND [Location]=" & strLocation & " AND [Start] = """ &
tdystart & """")


How can I find my appointments set to all day event?

Thanks for your help !!
Esperanza
 
S

Sue Mosher [MVP]

Have you tried using a format that includes the time (always 12:00 AM for all-day events)? That's what worked for me:

strFind = "[Start] = " & Chr(34) & "9 Sep 2003 12:00 AM" & Chr(34) & " AND [AllDayEvent] = True"

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
K

Ken Slovak - [MVP - Outlook]

I did some testing on this with variations of the Find string. If the
appointment is not an all day event you can use Start as a search
condition, if it is an all day event the same appointment isn't
returned when Start is used.

If I search for an all day event using this string:
strFind = "[AllDayEvent] = " & vbTrue
I get an all day appointment.

Therefore I'd use something like the following restriction. You can
then check each item returned for the Start date using brute force.

strFind = "[Subject] = '" & _
strActivite & "' AND [Location]= '" & strLocation & _
"' AND [AllDayEvent] = " & vbTrue


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
 
E

Esperanza

I am sending you a response I received from LambiekNL from
another newsgroup (microsoft.public.vb.general.discussion) which works
great .
Esperanza,

I tried your examples and read some info at Microsoft MSDN about it:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/_o
lemsg_alldayevent_property_appointmentitem_object_.asp

If you read the 'If you change AllDayEvent from False to True...' section
notice that if a appointment is set to AllDayEvent the Start time is set to
midnight

So, if you change your tdystart from "09-09-2003" to "09-09-2003 00:00" the
function works (at my side)

The function I used now is:

Set oCalendarFolder =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar)
strActivite = "test invitation"
strLocation = "here"
tdystart = "09/09/03 00:00"
Set oApptitem = oCalendarFolder.Items.Find("[subject] = " & Chr$(34) &
strActivite & Chr$(34) & " AND [Location]=" & Chr$(34) & strLocation &
Chr$(34) & " AND [Start] = " & Chr$(34) & tdystart & Chr$(34) & " AND
[AllDayEvent]= " & Chr$(34) & "True" & Chr$(34))
MsgBox oApptitem.Start
set aApptitem = Nothing

Please, give it a try...

Note: for my own readability I used Chr$(34) to place a "

With kind regards,

LambiekNL



Ken Slovak - said:
I did some testing on this with variations of the Find string. If the
appointment is not an all day event you can use Start as a search
condition, if it is an all day event the same appointment isn't
returned when Start is used.

If I search for an all day event using this string:
strFind = "[AllDayEvent] = " & vbTrue
I get an all day appointment.

Therefore I'd use something like the following restriction. You can
then check each item returned for the Start date using brute force.

strFind = "[Subject] = '" & _
strActivite & "' AND [Location]= '" & strLocation & _
"' AND [AllDayEvent] = " & vbTrue


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Esperanza said:
I tried the following :

Set oApptItem = oCalendarFolder.Items.Find("[subject] = " & strActivite & "
AND [Location]=" & strLocation & " AND [Start] = """ & tdystart & """" & "
AND [AllDayEvent]= " & 1)

Guess what , couldn't find anything.
My variable date tdystart = "21-08-2003".
Maybe there something wrong with it. Maybe the program need another format
when set to AllDayEvent ?

Esperanza
 

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