F
fruitchunk
I have a VBA code to export tasks to outlook.
It works ok but it just dumps all the tasks to outlook.
Is there a better VBA code for me?
Is there away I can export only selected tasks not all of them?
Can "summary tasks" be exported as categories in outlook?
this is the code I use:
from http://www.outlookcode.com/codedetail.aspx?id=1165
Sub OutlookLink()
Dim appOL As Outlook.Application
Dim mspTask As MSProject.Task
Dim olTask As Outlook.TaskItem
Dim i As Integer
On Error GoTo objerror
Set appOL = GetObject(, "Outlook.Application") ' if Outlook is running,
this line will work
resumeplace:
For Each mspTask In MSProject.ActiveProject.Tasks
If Not (mspTask Is Nothing) Then
Set olTask = appOL.CreateItem(olTaskItem)
'note that you can capture other Project fields into Outlook fields
olTask.Subject = mspTask.Name
olTask.Body = mspTask.Name
olTask.DueDate = mspTask.EarlyFinish
olTask.StartDate = mspTask.EarlyStart
olTask.Role = mspTask.ID
olTask.PercentComplete = mspTask.PercentComplete
olTask.Save
Set olTask = Nothing
End If
i = i + 1
Next
MsgBox "Cheryl, " & i & " tasks were exported to Outlook!"
Exit Sub
objerror: ' if Outlook is not running, this will work
Err.Clear
Set appOL = CreateObject("Outlook.Application")
GoTo resumeplace
End Sub
It works ok but it just dumps all the tasks to outlook.
Is there a better VBA code for me?
Is there away I can export only selected tasks not all of them?
Can "summary tasks" be exported as categories in outlook?
this is the code I use:
from http://www.outlookcode.com/codedetail.aspx?id=1165
Sub OutlookLink()
Dim appOL As Outlook.Application
Dim mspTask As MSProject.Task
Dim olTask As Outlook.TaskItem
Dim i As Integer
On Error GoTo objerror
Set appOL = GetObject(, "Outlook.Application") ' if Outlook is running,
this line will work
resumeplace:
For Each mspTask In MSProject.ActiveProject.Tasks
If Not (mspTask Is Nothing) Then
Set olTask = appOL.CreateItem(olTaskItem)
'note that you can capture other Project fields into Outlook fields
olTask.Subject = mspTask.Name
olTask.Body = mspTask.Name
olTask.DueDate = mspTask.EarlyFinish
olTask.StartDate = mspTask.EarlyStart
olTask.Role = mspTask.ID
olTask.PercentComplete = mspTask.PercentComplete
olTask.Save
Set olTask = Nothing
End If
i = i + 1
Next
MsgBox "Cheryl, " & i & " tasks were exported to Outlook!"
Exit Sub
objerror: ' if Outlook is not running, this will work
Err.Clear
Set appOL = CreateObject("Outlook.Application")
GoTo resumeplace
End Sub