Geeks With Blogs
Random Musing Putting it together one piece at a time...

If you are a Project Manager, or have in any way been involved in a project which require you to use Project 2003, there is probably a time when you wish for some way to export your Project tasks out into Outlook 2003. There is an easy way to import Outlook task into Project 2003, but not the other way round. It seem more natural and obvious to have tasks defined and sorted out in Project 2003 first, and have them exported into Outlook for your action.

The simpliest way around this problem is to use VBA. Appended below are 2 simple VBA scripts, one for exporting from Project to Outlook, and the other to update the status from Outlook back to Project:


'#1 - From Project to Outlook
'To be saved into Project 2003 as macro


Sub ExportTask()
    Dim appOL As Outlook.Application
    Dim mspTask As MSProject.Task
    Dim olTask As Outlook.TaskItem
    Dim TaskFolder As MAPIFolder
    Dim checkTask As String
    Dim i As Integer, j As Integer
   
    On Error GoTo objError
    Set appOL = GetObject(, "Outlook.Application")
   
resumeplace:
    Set TaskFolder = appOL.GetNamespace("MAPI").GetDefaultFolder(olFolderTasks)
    For Each mspTask In MSProject.ActiveSelection.Tasks
        If Not (mspTask Is Nothing) And Not (mspTask.Summary = True) Then
            checkTask = "[Subject] = """ & mspTask.Name & """"
            If TaskFolder.Items.Find(checkTask) Is Nothing Then
                Set olTask = appOL.CreateItem(olTaskItem)
                olTask.Subject = mspTask.Name
                olTask.Body = mspTask.Notes
                olTask.StartDate = mspTask.EarlyStart
                olTask.DueDate = mspTask.EarlyFinish
                olTask.Status = olTaskNotStarted
                'olTask.Categories = "Work"
                olTask.Categories = Left(MSProject.ActiveProject.Name, Len(MSProject.ActiveProject.Name) - 4)
                olTask.Mileage = mspTask.ID
                olTask.ReminderSet = False
                olTask.Save
                Set olTask = Nothing
                i = i + 1
            Else
                MsgBox "[" & mspTask.Name & "] already existed, task skipped"
            End If
        End If
    Next
    MsgBox "Export completed. " & i & " tasks were exported to Outlook."
    Exit Sub
   
objError:
    Err.Clear
    Set appOL = CreateObject("Outlook.Application")
    GoTo resumeplace
End Sub



'#2 - From Outlook to Project
'To be saved into Outlook 2003 as macro


Sub UpdateTask()
    Dim appPro As MSProject.Application
    Dim mspTask As MSProject.Task
    Dim olTask As Outlook.TaskItem
    Dim TaskFolder As MAPIFolder
    Dim checkTask As String
    Dim i As Integer, j As Integer
   
    On Error GoTo objError
    Set appPro = GetObject(, "MSProject.Application")
   
resumeplace:
    'Get the category first - matched to the name of the project
    If Outlook.Application.ActiveExplorer.CurrentFolder = "Tasks" Then
        For i = 1 To Outlook.Application.ActiveExplorer.Selection.Count
            Set olTask = Outlook.Application.ActiveExplorer.Selection.Item(i)
            If olTask.Mileage <> "" Then
                'Set mspTask = appPro.ActiveProject.Tasks(CInt(olTask.Mileage))
                If appPro.Projects.Count = 0 Then
                    MsgBox "Please open Project first before proceeding"
                    Exit For
                Else
                    Set mspTask = appPro.Projects.Item(olTask.Categories).Tasks(CInt(olTask.Mileage))
                    mspTask.PercentComplete = olTask.PercentComplete
                End If
            Else
                MsgBox "[" & olTask.Subject & "] is not a Project task. Task skipped."
            End If
            j = j + 1
        Next
        MsgBox "Update completed. " & j & " tasks were updated to Project."
    Else
        MsgBox "Please select [Task] folder before running"
    End If

    Exit Sub
   
objError:
    Err.Clear
    Set appPro = CreateObject("MSProject.Application")
    GoTo resumeplace

End Sub


You have to have both Project 2003 and Outlook 2003 to be open to prevent unneccessary troubleshoots. Simply paste the relevant scripts into its respective application. You can create a hotkey to execute the Project 2003's macro from the options menu in the macro page

As for outlook, assign a button to that macro and have it placed on your toolbar for easy access

To export out from Project into Outlook, simply select your tasks, and do a "Ctrl E". A few days later, when you're done with your task, mark them as 'completed' in Outlook and click the 'Update Project' to have its Project's counterpart updated.

I hope these simple VBA scripts will help enhance your productivity.

Posted on Friday, December 29, 2006 4:25 PM Project Management , General Stuff | Back to top


Comments on this post: MS Project 2003 Tasks and Outlook 2003 Tasks

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Hello -

Thanks for posting the code, but I get an error in both Outlook & Project - both return "Compile Error - User Defined Object not defined" after I try to run the macros. This would be most useful for me, and I'd love to find out how to fix this problem.
Left by Danny on Jan 18, 2007 2:42 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
You can try opening the VBA editor from either your outlook or project, depending on which one you refer to debug first, and do a line by line debug by pressing F8, so that you will know where the error lies in.

I suspect that it might be somethere in the latebinding but I can't be sure. These scripts are highly customized for personal usage so some very minor modification might be required....

let me know again if u need help..
Left by Nestor on Jan 18, 2007 8:28 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
In VisualBasic go to the "Tools" menu, select "References...", scroll down to find "Microsoft Outlook xx.x Object Library". Click the check box, click the "OK" button. Should work after that.
Left by KMyers on Nov 02, 2007 6:06 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Hi great idea (but I wonder why Microsoft don't have this as basic functionality?)

I set up a trial with a project made up of three sub tasks all linked one after the other.

The export to Outlook sort of worked, the first task was missed (maybe because it was scheduled today for 1 day duration) the second task arrived OK, the third task was missing (because it was dependent on task 2?)

I updated progress to 75% and tried to update Project from Outlook but got

Run-time error '424'
Object required

with this line of the macro highlighted

Set mspTask = appPro.Projects.Item(olTask.Categories).Tasks(CInt(olTask.Mileage))

Hope this is useful feedback, good luck with your programming.

Cheers
Steve
Left by steve yates on Nov 05, 2007 5:53 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
I am new to MPP and the Outlook and so need some help here.

1. How do I "assign a button to that macro and have it placed on your toolbar for easy access"

2. When I run the Macro, I get compile error - 'User defined type not defined' on the first line "Dim appOL As Outlook.Application".

any help ?

thanks
Left by Gopal on Nov 07, 2007 12:58 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Same issue as Gopal, please tell me how to correct the macro, this would be a great Xmas present!
Left by Wayne Hyrkas on Dec 19, 2007 4:33 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
ANYONE HAVE A FIX FOR THE RUNTIME ERROR 424 DESCRIBED BY STEVE ABOVE?
Left by JAMEY on Jan 21, 2008 5:40 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
This could be due to the different version of Outlook that you are using. You can try to look at the object browser to see if it's there
Left by Nestor on Jan 21, 2008 11:24 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Hi Jamey,

This is probably because your appPro or the olTask is not assigned the respective object. appPro is the Microsoft Project application itself and olTask is suppose to be the selected task.

Try opening both outlook and project, and select the task to import/export before hitting the macro.

Left by Nestor on Jan 21, 2008 11:27 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Hi I'm running into the same thing as Gopal and I have outlook/project 2003. I opened both outlook and project and selected the task - I still got the error. Anyone else still get the error or am I missing something even more basic?

I'm excited about this! I hope we can get it to work.

Dana

Left by Dana on Jan 30, 2008 7:19 PM

# Another way...
Requesting Gravatar...
Another (less elegant, but workable) method is to export the project data as an .xls, then import into Otlook. You'll need to experiment a few times to make it work; it took me about half an hour to fiddle till it worked for me. It's probably a good idea to test using a new calendar (in Outlook: R-click on the Mailbox, then choose New Folder, type Calendar, and enter a name for it) for testing.
Left by STD on Feb 06, 2008 2:55 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
When you cut and paste the code in one block, the break between the two macros copies as:

------------------------------------------------------------------

Once I deleted this and saved, I had no problem.
Left by Anonymous on Feb 21, 2008 1:42 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
This is really great, it helped me a lot, thank you
Left by Bilal on Feb 29, 2008 1:09 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
I'm glad it worked for you!
Left by Nestor on May 06, 2008 8:37 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Dana,

you should look at solution given by KMyers.

cheers
Left by Harry on May 22, 2008 1:57 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
hi it worked fine with MSproject to outlook
but from outlook to MSProject it is giving same error as object needed
pl help me what to do?
Left by vishesh on Jun 18, 2008 3:45 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
In VisualBasic go to the "Tools" menu, select "References...", scroll down to find "Microsoft Outlook xx.x Object Library". Click the check box, click the "OK" button. Should work after that.

Hi,
I am following this.
The script is highlighted yellow on:
Sub ExportTask()
Tried to open References but it is not On i.e. Grey-out.
Any step-by-step suggestion as to how can I follow your steps?
Thank you in advance
TJ
Left by Tj on Jul 23, 2008 7:26 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
KMyers:

Thank you it worked...I am new to VB actually. For others, a little addition to KMyers fix:

In Ms-Project, on macro error:
1. select the "Debug" first and then the Tool>References>Microsoft Outlook xx.x Object Library

In Ms-outlook, on macro error:
1. select the "Debug" first and then the Tool>References>Microsoft Project xx.x Object Library

Error in Outlook?
When updating Project from Outlook, it says:
[Task Name] is not a Project Task. Task Skipped
Soon after OK, it says:
Update Completed....

Any idea what is that all about?
Also, which project will be updated with these tasks? I understand the one which will be opened. Correct?

Tj

Left by Tj on Jul 23, 2008 8:29 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Im already activate in Outlook and project the references, but still having the error, the difference is Im using Outlook 2007. is there any changes about Outlook 2007?
Left by Rub on Jul 30, 2008 10:00 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
I am getting the following error when attempting to update a task from Outlook to MS Project:

Run time error '1004':

An unexpected error occured with the method

When I go into debug it is on line:

Set mspTask = appPro.Projects.Item(olTask.Categories).Tasks(CInt(olTask.Mileage))

Any ideas? Thanks,

NSP
Left by Needles62 on Aug 16, 2008 5:41 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
THANK YOU SO MUCH FOR SHARING THE KNOWLEDGE, YOU SAVE MY DAY!! YOUR GREAT MEN!! :)
Left by Carlos on Oct 03, 2008 6:49 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
This wroked very well. Simple yet powerful. Thanks!!!
Left by Ram on Oct 23, 2008 5:39 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
I've been attempting to use this, and it looks to be an absolute life saver!!!

however I have a "slight" issue that Outlook wont update in to Project it keeps asking me to select a task. I've tried many ways even selecting all, deleting all the tasks and recreating some to no avail.

Dave
Left by Dave on Oct 28, 2008 7:37 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Any way to send the tasks to the resource name instead of all sending to the project owner?
Left by Joanne on Nov 03, 2008 10:49 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
You are a god send!! This solves so many issues in following up schedules. Thanks much! Where do I donate some money! You made me extremely productive
Left by Ravi on Nov 13, 2008 4:10 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Please how can sentt tasks from project to outlook.Do you have any programm.
Left by George Skilas on Dec 10, 2008 4:19 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Please if anybody can assist me in this, I dont have any VBA experiance but need this issue critically. If anyone can give me a step by step on how to enter the code (and where). I would greatly appreciate this.
Left by Mohammed on Dec 18, 2008 3:27 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
I have succeed to update outlook calendar from ms project.
But I have two calendars in my outlook. One of them is shared with someother people. Does anyone knows how I will define which calendar to update using vb?

Thanks in advance,
Left by Antonis on Jan 09, 2009 10:18 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Thanks a million... Your project to outlook worked like a charm
Left by Isaack on Feb 12, 2009 10:19 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
The Run-time error '424', Object required was solved for me when I saved the project file before updating the tasks.
Left by Andrew on Feb 18, 2009 11:57 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
I got the Project macro to save but I am having trouble with outlook they are both 2003 pro. I am on xp.

When i go to the macro window all the buttons are grayed out but cancel. I could swear that the first time i tried it was not but then i got an error which I don't remember now as it was hours ago and many other attempts previously. But now nothing I have tried has corrected the grayed out button issue. Any ideas? Thanks!
Left by flyrr on Feb 21, 2009 3:37 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
What about MS Project 2007 Tasks and Outlook 2007 Tasks
Left by Nick George on Apr 03, 2009 6:46 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Good one.. I added MS Office Outlook and project references in both the apps, my error gone.. Thank You.. :)
Left by R on Apr 28, 2009 2:04 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
I have tried all of the suggestions on this page, and I still get a 424 error message when I try to update Project from Outlook...any other suggestions? I am not a programmer.
Left by LynnM on May 06, 2009 3:19 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Run this with Outlook 2003 / MSProject 2007 no problems except the tweeks on tools>reference> ****.object library advised.

Had to do this on Project(refering MSOutlook.objectlibrary) and on Outlook (referencing MSProject.objectlibrary)

Cheers,
SevenM
Left by SevenM on May 11, 2009 10:04 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Thanks its greate. I tried it on 2007 and it worked fine.

thanks alot
Left by Mahmoud Hamdan on May 13, 2009 9:16 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Question.

I have multiple projects here the tasks have the same name.
When importing the first project to Outlook the MSproject name comes under category and it is all fine.
When I import the second project because the tasks have the same name the import is refused.

How can I change the code to add a "check if category will be the same" line? Should be something around checkTask = "[Subject] = """ & mspTask.Name & """"

That would give me the ability to include and sort various projects on the task pane.

Again,
Thank you to everyone involved in developing this. I am way more productive due to this little tools.

Miguel


Left by SevenM on May 13, 2009 9:58 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
HI!

Got it to work by replacing checktask to :

checkTask = "[Subject] = """ & mspTask.Name & Left(MSProject.ActiveProject.Name, Len(MSProject.ActiveProject.Name) - 4) & """"

With this, the name of the project will be added as category even if the tasks being added exist with the same sname on Outlook.

ie:
you have
project A task1
task2
project B task1 and task2

this will be added to Outlook as
CategoryA task1 and
Left by SevenM on May 22, 2009 10:25 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Now we only need Task-to-Calendar appointment
VB/Macro code :)))

...There is simply no pleasing some people...

Cheers!!
Miguel
Left by SevenM on May 23, 2009 12:04 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Is it possible to export from Project to the Resources Tasks?
Left by Brian on May 30, 2009 5:30 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Great script, thanks. I have it working going both from Project --> Outlook and back fine.

I would love to see an extension to this though, whereby the DateCompleted task property from Outlook could update the ActualFinish property in Project. This would allow me to assign resources tasks, for them to update them with the actual finish date of a task. I would then run the Outlook-Project script which would allow me to see if my project is running correctly.

I can't code VBA, but if someone could extend this script, that would be great!

Thanks,

Rich
Left by Rich F on Jul 02, 2009 5:09 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Great bit of work and it helped a novice like me who has very little VB knowledge...Ta.

Just one question though...is it possible to bring the resources aasigned to a task through with the info as well so that I can fire this off to them.

Cheers

Ben
Left by Ben C on Aug 13, 2009 9:06 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Hi,
I am getting the following error:
Compilation Error: Assignment to constant not permitted.

the highlighted code is :
Set olTask = appOL.CreateItem(olTaskItem)

Can someone help here.
I am new to VBA.

Thanks!!!
Left by Ashutosh on Aug 20, 2009 12:18 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Any solution for exporting from MS Project 2007 to MS Outlook 2007? Or will the original VBA code work with just a few tweaks perhaps?
Left by Bob on Sep 01, 2009 2:55 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
i got the script to work great as it saying that tasks have been exported. But I can't seem to be able to find them in outlook. any ideas?
Left by Wassim on Jan 07, 2010 5:10 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
This is great, thanks for the efforts.

One issue however is that if I work within project and dates change for a task, it doesn't update the dates for these tasks in Outlook, does it?
Left by Craig on Apr 21, 2010 8:04 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
What about MS Project 2010 Tasks and Outlook 2010 Tasks.
Do you have any idea?
Left by Kursk on Aug 18, 2010 11:54 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
First of all: THANKS for sharing this. Great tools!

For those who get the "Object required" error: This only means that you have no tasks selected in MS Project at the time you ran the macro.

More interesting, the macro only exports those tasks that are selected. Which is a neat feature.

The code that "breaks" when you don't have any tasks selected is the following line:

For Each mspTask In MSProject.ActiveSelection.Tasks

Cheers,

-gt
Left by gtempo on Sep 04, 2010 8:09 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Cool. It works perpectly.

I got the same issue "Compile Error - User Defined Object not defined" but when i added MS Outlook 11.0 Object Lib then it runs properly.

Thanks
Left by Hoan DINH on Sep 05, 2010 10:12 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
This is awesome, thank you so much!!
Left by Mike Hall on Sep 09, 2010 10:41 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Hello
this is a brilliant tool, I am still having issues on the Outlook to Project part, followed the instructions but getting Compile error: Syntax error box on the line Set mspTask =
any ideas?

Also I think people have already asked for the ability to transfer Resources into Outlook tasks and making them completion date in Outlook the date inserted into Project. Anyone cracked this yet?

Once again thanks everyone for this - its brilliant.
Left by Mandy S on Sep 28, 2010 7:43 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Hi,

The tool seems to work as the macro runs and the dialogue box tells me the data has been exported, however when i look in outlook the projects have not been exported>? Would really appreciate an answer, since this turn around is incredible useful!!

MANY THANKS,

Shak
Left by Shak on Oct 15, 2010 5:58 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Hello, I have the same issue as Shak's. Please tell us what we should do?

Thanks in advance,

Thu
Left by Thu on Jan 12, 2011 1:56 AM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Awesome for going from Project to Outlook but I'm having an error going from outlook to project.

Run-time error '1004'
An unexpected error occured within the method

it happens here:
Set mspTask = appPro.Projects.Item(olTask.Categories).Tasks(CInt(olTask.Mileage))

any thoughts? I tried closing and restarting, all the references are good (I think)

Thank you for this code!
Left by Bryan on Feb 08, 2011 12:58 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Great tools!
Thanks for good job!
Left by Sang on Sep 29, 2011 11:34 PM

# re: MS Project 2003 Tasks and Outlook 2003 Tasks
Requesting Gravatar...
Many thanks to Nestor for sharing this code. After trying it out i would suggest using mspTask.UniqueID as the link between project and corresponding outlook tasks rather than mspTask.ID which can change if you move the tasks about in project:

'#1 - From Project to Outlook:

olTask.Mileage = mspTask.UniqueID

'#2 - From Outlook to Project:

Set mspTask = appPro.Projects.item(olTask.Categories).Tasks.UniqueID(CInt(olTask.Mileage))

Thanks again!
Left by Jimmy on Mar 23, 2013 12:29 AM

Your comment:
 (will show your gravatar)


Copyright © Nestor | Powered by: GeeksWithBlogs.net