Updating a TASK

  • Thread starter Thread starter Rick Cassani
  • Start date Start date
R

Rick Cassani

All,
I've created an Outlook Task from Great Plains via VBA. The application now
calls for the ability to modify the Due Date. Is there a way to identify,
find, and modify the due date on the Task I've already created?

Thanks,
Rick
 
TaskItem.DueDate is the property you need to change. You can find the task
by checking each item in the folder for an item with the subject of the task
you created, or you can look at some other distinct property.

To avoid looping through each item you can use Find, see www.outlookcode.com
for syntax for that. If you have the original item and can access it you can
get its EntryID property and use that with the NameSpace.GetItemFromID
method to get the task directly.
 
Here's a macro to retrieve a Task by its subject line in your default Tasks
folder and set the DueDate property:

Sub UpdateTaskDueDate()
On Error Resume Next

Dim objTask As Outlook.TaskItem, objTaskFolder As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItems As Outlook.Items

Set objNS = Application.GetNamespace("MAPI")
Set objTaskFolder = objNS.GetDefaultFolder(olFolderTasks)
Set objItems = objTaskFolder.Items.Restrict("[Subject] = 'Task Subject
Text')

If Not objItems.Count = 0 Then
Set objTask = objItems.Item(1)
objTask.DueDate = #12/31/2004#
objTask.Save
End If

Set objNS = Nothing
Set objTaskFolder = Nothing
Set objTask = Nothing
Set objItems = Nothing
End Sub
 
Did I mention that the Task does not exist on the same PC as the
application? I assigned the Task to a Recipient. So... can I still retrieve
the specific Task from someone else's default folder?


Eric Legault said:
Here's a macro to retrieve a Task by its subject line in your default Tasks
folder and set the DueDate property:

Sub UpdateTaskDueDate()
On Error Resume Next

Dim objTask As Outlook.TaskItem, objTaskFolder As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItems As Outlook.Items

Set objNS = Application.GetNamespace("MAPI")
Set objTaskFolder = objNS.GetDefaultFolder(olFolderTasks)
Set objItems = objTaskFolder.Items.Restrict("[Subject] = 'Task Subject
Text')

If Not objItems.Count = 0 Then
Set objTask = objItems.Item(1)
objTask.DueDate = #12/31/2004#
objTask.Save
End If

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

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

Rick Cassani said:
All,
I've created an Outlook Task from Great Plains via VBA. The application now
calls for the ability to modify the Due Date. Is there a way to identify,
find, and modify the due date on the Task I've already created?

Thanks,
Rick
 
I assume you are using Exchange? If so, and they have delegated Author
permissions on their Tasks folder, you can use the GetSharedDefaultFolder
method instead of GetDefaultFolder (passing the appropriate Recipient and
FolderType arguments).

See the GetSharedDefaultFolder method section of the Outlook VBA help file
for a good example.

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

Rick Cassani said:
Did I mention that the Task does not exist on the same PC as the
application? I assigned the Task to a Recipient. So... can I still retrieve
the specific Task from someone else's default folder?


Eric Legault said:
Here's a macro to retrieve a Task by its subject line in your default Tasks
folder and set the DueDate property:

Sub UpdateTaskDueDate()
On Error Resume Next

Dim objTask As Outlook.TaskItem, objTaskFolder As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItems As Outlook.Items

Set objNS = Application.GetNamespace("MAPI")
Set objTaskFolder = objNS.GetDefaultFolder(olFolderTasks)
Set objItems = objTaskFolder.Items.Restrict("[Subject] = 'Task Subject
Text')

If Not objItems.Count = 0 Then
Set objTask = objItems.Item(1)
objTask.DueDate = #12/31/2004#
objTask.Save
End If

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

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

Rick Cassani said:
All,
I've created an Outlook Task from Great Plains via VBA. The application now
calls for the ability to modify the Due Date. Is there a way to identify,
find, and modify the due date on the Task I've already created?

Thanks,
Rick
 
Back
Top