Roland Askew
Member
- Outlook version
- Outlook 2021 64 bit
- Email Account
- IMAP
I am trying to search through my task that have a userproperties field "Project". I want to loop through all the tasks that have an entry and ignore the task where the field is blank. I have not been able to work out how to search is not blank.
So far I have the following code which finds the tasks which have "test project" as a value in the project field and displays them. Any help to search for all tasks that the Project field is not empty would be really helpful.
Thanks
Roland
Public Sub Project()
Dim ns As NameSpace
Dim objFolder As MAPIFolder
Dim currrentItem As Object
Dim objTasks As TaskItem
Dim colItems As items
Set ns = Application.GetNamespace("MAPI")
Set objFolder = ns.GetDefaultFolder(olFolderTasks)
Set objItem = objFolder.items
Dim strWhere As String
strWhere = "[Project] = 'Test Project'"
Set colItems = objFolder.items.Restrict(strWhere)
For Each Item In colItems
Item.Display
Next
End Sub
So far I have the following code which finds the tasks which have "test project" as a value in the project field and displays them. Any help to search for all tasks that the Project field is not empty would be really helpful.
Thanks
Roland
Public Sub Project()
Dim ns As NameSpace
Dim objFolder As MAPIFolder
Dim currrentItem As Object
Dim objTasks As TaskItem
Dim colItems As items
Set ns = Application.GetNamespace("MAPI")
Set objFolder = ns.GetDefaultFolder(olFolderTasks)
Set objItem = objFolder.items
Dim strWhere As String
strWhere = "[Project] = 'Test Project'"
Set colItems = objFolder.items.Restrict(strWhere)
For Each Item In colItems
Item.Display
Next
End Sub