Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Find Calendar Item from Location (http://www.outlookbanter.com/outlook-vba/31691-find-calendar-item-location.html)

mrdonofrio November 1st 06 05:47 PM

Find Calendar Item from Location
 
Hi

I have read the posts regarding finding by location - i can get my code
to work by looping through each item until i get to the correct record
however i cannot get the code to the record.

I am probably missing something vey simple but cannot get this to work.

Thank in advance



Public Function OutLookCode()

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.Folders("Public Folders").Folders("All
Public Folders").Folders("RRES Public
Folders").Folders("ROTH").Folders("Facilities").Fo lders("Conference
Centre").Folders("Elliott Suite")
Set colItems = objFolder.Items

strTest = colItems.Count

Set objItem = colItems.Find(Location = "99999999999") '****** This line
does not work and returns the error 'Condition not valid'


******** This works fine if the above is comented out
For Each objItem In colItems
If objItem.Location = "99999999999" Then
With objItem
strTest = objItem.Subject
End With
End If
Next

End Function


mrdonofrio November 1st 06 06:29 PM

Find Calendar Item from Location
 
Sorry this should have read

I have read the posts regarding finding by location - i can get my code
to work by looping through each item until i get to the correct record
however i cannot get the code to FIND the record.

mrdonofrio wrote:

Hi

I have read the posts regarding finding by location - i can get my code
to work by looping through each item until i get to the correct record
however i cannot get the code to the record.

I am probably missing something vey simple but cannot get this to work.

Thank in advance



Public Function OutLookCode()

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.Folders("Public Folders").Folders("All
Public Folders").Folders("RRES Public
Folders").Folders("ROTH").Folders("Facilities").Fo lders("Conference
Centre").Folders("Elliott Suite")
Set colItems = objFolder.Items

strTest = colItems.Count

Set objItem = colItems.Find(Location = "99999999999") '****** This line
does not work and returns the error 'Condition not valid'


******** This works fine if the above is comented out
For Each objItem In colItems
If objItem.Location = "99999999999" Then
With objItem
strTest = objItem.Subject
End With
End If
Next

End Function



Eric Legault [MVP - Outlook] November 1st 06 06:36 PM

Find Calendar Item from Location
 
The search string is in the wrong format:

Set objItem = colItems.Find("[Location] = ""99999999999""")

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"mrdonofrio" wrote:

Hi

I have read the posts regarding finding by location - i can get my code
to work by looping through each item until i get to the correct record
however i cannot get the code to the record.

I am probably missing something vey simple but cannot get this to work.

Thank in advance



Public Function OutLookCode()

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.Folders("Public Folders").Folders("All
Public Folders").Folders("RRES Public
Folders").Folders("ROTH").Folders("Facilities").Fo lders("Conference
Centre").Folders("Elliott Suite")
Set colItems = objFolder.Items

strTest = colItems.Count

Set objItem = colItems.Find(Location = "99999999999") '****** This line
does not work and returns the error 'Condition not valid'


******** This works fine if the above is comented out
For Each objItem In colItems
If objItem.Location = "99999999999" Then
With objItem
strTest = objItem.Subject
End With
End If
Next

End Function



mrdonofrio November 2nd 06 12:13 PM

Find Calendar Item from Location
 
Hi Eric

Thanks for that - you code actually came back with another error -
Uanble to parse condition. Error at ""99999999".

So i changed the code to this and it works perfectly

Set objItem = calItems.Find("[Location] =" & 999999999)

Thanks for your help - much appreciated

Marc



All times are GMT +1. The time now is 08:18 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