By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,536 Members | 2,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,536 IT Pros & Developers. It's quick & easy.

How to read all Outlook task fields in Access database.

P: 1
I am trying to wite a vba code to read all my outlook task fields in Access database. So far I have following code:
Expand|Select|Wrap|Line Numbers
  1. Sub OutlookTasks()
  3. Dim ol As Object
  4. Dim olns As Object
  5. Dim objFolder As Object
  6. Dim objAllTasks As Object
  7. Dim Task As Object
  8. ' Set the Application object.
  9. Set ol = New Outlook.Application
  10. ' Set the Namespace object.
  11. Set olns = ol.GetNamespace("MAPI")
  12. ' Set the default Tasks folder.
  13. Set objFolder = olns.GetDefaultFolder(olFolderTasks)
  14. ' Set objAllTasks equal to the collection of all Tasks.
  15. Set objAllTasks = objFolder.Items
  16. ' Loop through each Task.
  17. For Each Task In objAllTasks
  18. ' Display the Body field for the Task.
  19. MsgBox "Task: " & Task.Subject & " Last Update: " & Task.Role
  20. Next
  21. End Sub
I am getting a "compile error: user-defined type not defined" error. I am a total amateur in vba, any help would be great!
May 7 '10 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 931

I think you need to set a reference for Access VBA to be able to communicate with Outlook. For instance, in 2007 you go Tools > References... and then scroll down the list and check mark "Microsoft Outlook 12.0 Object Library" and click OK.

The code should compile after setting the proper reference.

May 7 '10 #2

P: 15
Can you just attach to the PST file and reference it from a linked table?
May 9 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.