A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to loop through Outlook tasks in VBA



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 23rd 06, 05:33 PM posted to microsoft.public.outlook.program_vba
Rick Williams
external usenet poster
 
Posts: 4
Default How to loop through Outlook tasks in VBA

I have a macro in MS Project that moves all the Project tasks to Outlook.
Now I need to be able to loop through all the tasks in Outlook so that I can
gather status info and use it to update MS Project. But I can't figure out a
way to get a reference to each Outlook task.

Can anyone help? I will gladly post the MSProject-to-Outlook-task code if
anyone wants to see it.

Thanks,
Rick Williams


Ads
  #2  
Old January 25th 06, 05:32 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default How to loop through Outlook tasks in VBA

You can iterate through all the Tasks in the default Tasks folder using a
macro like this:

Sub LoopThroughTasks()
Dim objTask As Outlook.TaskItem, objTaskFolder As Outlook.MAPIFolder
Dim objTaskItems As Outlook.Items, objNS As Outlook.NameSpace

Set objNS = Application.GetNamespace("MAPI")
Set objTaskFolder = objNS.GetDefaultFolder(olFolderTasks)
Set objTaskItems = objTaskFolder.Items

For Each objTask In objTaskItems
Debug.Print objTask.Status
'Returns value of olTaskStatus constants:
'olTaskComplete 2
'olTaskDeferred 4
'olTaskInProgress 1
'olTaskNotStarted 0
'olTaskWaiting 3
Next

Set objTask = Nothing
Set objTaskItems = Nothing
Set objTaskFolder = Nothing
Set objNS = Nothing
End Sub

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Rick Williams" wrote:

I have a macro in MS Project that moves all the Project tasks to Outlook.
Now I need to be able to loop through all the tasks in Outlook so that I can
gather status info and use it to update MS Project. But I can't figure out a
way to get a reference to each Outlook task.

Can anyone help? I will gladly post the MSProject-to-Outlook-task code if
anyone wants to see it.

Thanks,
Rick Williams



  #3  
Old January 25th 06, 08:59 PM posted to microsoft.public.outlook.program_vba
Rick Williams
external usenet poster
 
Posts: 4
Default How to loop through Outlook tasks in VBA

Thank you very much, Eric!
Rick Williams

"Eric Legault [MVP - Outlook]" wrote in
message ...
You can iterate through all the Tasks in the default Tasks folder using a
macro like this:

Sub LoopThroughTasks()
Dim objTask As Outlook.TaskItem, objTaskFolder As Outlook.MAPIFolder
Dim objTaskItems As Outlook.Items, objNS As Outlook.NameSpace

Set objNS = Application.GetNamespace("MAPI")
Set objTaskFolder = objNS.GetDefaultFolder(olFolderTasks)
Set objTaskItems = objTaskFolder.Items

For Each objTask In objTaskItems
Debug.Print objTask.Status
'Returns value of olTaskStatus constants:
'olTaskComplete 2
'olTaskDeferred 4
'olTaskInProgress 1
'olTaskNotStarted 0
'olTaskWaiting 3
Next

Set objTask = Nothing
Set objTaskItems = Nothing
Set objTaskFolder = Nothing
Set objNS = Nothing
End Sub

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Rick Williams" wrote:

I have a macro in MS Project that moves all the Project tasks to Outlook.
Now I need to be able to loop through all the tasks in Outlook so that I
can
gather status info and use it to update MS Project. But I can't figure
out a
way to get a reference to each Outlook task.

Can anyone help? I will gladly post the MSProject-to-Outlook-task code if
anyone wants to see it.

Thanks,
Rick Williams





 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to apply vba code to OL2003 forms ? TimR Outlook - Using Contacts 1 February 17th 06 05:41 PM
Delete Custom Outlook Control thru Access VBA Sue Mosher [MVP-Outlook] Outlook - Using Forms 0 January 20th 06 06:29 PM
Outlook Connector for Domino and VBA question [email protected] Outlook and VBA 0 January 18th 06 09:56 AM
Can I use VBA to activate a hyperlink in Outlook? [email protected] Outlook and VBA 2 January 18th 06 01:57 AM
List of Outlook References Through VBA David Outlook - General Queries 0 January 11th 06 12:53 AM


All times are GMT +1. The time now is 08:45 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.