Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find a Task 1

Status
Not open for further replies.

Jellytree

Technical User
Dec 22, 2004
11
CA
I'm sure this is very simple, but I'm new to outlook and VBA, so my knowledge is pretty sketchy.

Through vba in Access, I need to determine if an Outlook Task exists with a certain name (file number) and return True or False. Can someone please show the way? TIA.
 
Hi JellyTree,

Check out the Tasks Collection Object in the vba Help file.

Cheers
 
Thanks, macropod. I have gotten this far, but for some reason it never seems to return true, always false. I've got something wrong somewhere, but don't have the experience or know-how to find it:

Code:
Dim objApplication2 As outlook.Application
Dim objNameSpace2 As outlook.NameSpace
Dim fdrTasks As outlook.MAPIFolder
Dim itmTasks As outlook.TaskItem
Dim strTask As String

Set objApplication2 = CreateObject("outlook.application")
Set objNameSpace2 = objApplication2.GetNamespace("MAPI")
Set fdrTasks = objNameSpace2.GetDefaultFolder(olFolderTasks)
strTask = "[Subject]=" & FileID
Set itmTasks = fdrTasks.Items.find(strTask)

    If itmTasks Is Nothing Then     'the Find failed
       IsTask = False
    Else
       IsTask = True
    End If
    

Set objApplication2 = Nothing
Set objNameSpace2 = Nothing
Set fdrTasks = Nothing
Set itmTasks = Nothing

I believe the error is on the following line, but no errors are given when the code is run:
Set itmTasks = fdrTasks.Items.find(strTask
 
And what about this ?
strTask = "[Subject]='" & FileID & "'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

A star to you! Worked like a charm. Thanks so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top