Create MS Outlook task object by Excel macro

I

Ivan

Dear all,

I am writing an Excel macro to create and assign outlook task with the
following codes:

Sub createTask()

Dim objTask As Outlook.TaskItem
Set objTask = OutApp.CreateItem(olTaskItem)
With objTask
.StartDate = "05/30/2006"
.DueDate = "05/31/2006"
.Subject = "Testing Task"
.Body = "Testing Task"
.Assign
.Recipients = "Michael Lurer"
.Send
End With
Set objTask = Nothing

End Sub
'********************************

However, the program got an error at the line .Recipients = "Michael Lurer"
and the error message is "Run-time error '-2147024809(80070057)': Could not
complete the operation. One or more parameter values are not valid".

But the name of recipient is a real name and exists in the Outlook address
book. Anyone knows how to solve this problem? Thanks in advance.

Ivan
 
S

Steve Yandl

Ivan,

Try
Set aRecipient = objTask.Recipients.Add("Michael Lurer")
I think you may also need to have a line with
objTask.Save

Steve
 
B

Bugman

Building on this same principle... I would like to copy and paste a selection
of visible cells (meaning some columns could be hidden) into the Body of a
task. I would also like to keep the MS Office Excel Worksheet format. I have
the following code:

Sub ScheduleTask()
Dim OLF As Outlook.MAPIFolder
Dim olTaskItem As Outlook.TaskItem

Set OLF = GetObject("",
"Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderTasks)
Set olTaskItem = OLF.Items.Add ' creates a new task
With olTaskItem
.Subject = ActiveCell.EntireRow.Cells(1, 1).Value
.DueDate = #2/1/2008#
.ReminderTime = #1/21/2008 1:00:00 PM#
.ReminderSet = True
.Body = ???

.Save
End With
Set olTaskItem = Nothing
Set OLF = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top