Recipients.Add method causing Error 287

Excel1user

New Member
Joined
May 20, 2013
Messages
6
I am writing vba code to create Outlook tasks for various employees from an Excel spreadsheet. The spreadsheet contains a list of reports under review and who is assigned to review the task.
I want the vba code to create an Outlook task for the individual assigned to review the report. I have found a number of websites with example code of how to do this, but everytime I have tried to use the code I get the same error on the "Recipients.Add" line. The error is vba "Run-time error '287': Application-defined or object-defined error".
Here is the code I'm using: (It is interesting to note that I have written code that successfully writes an e-mail, but that code uses the ".To" method, instead of the "Recipients.Add" method. Unfortunately the ".To" method is not available for Task Items.)
Rich (BB code):
Option Explicit
Sub createtask()
    Dim olApp As Outlook.Application, olNs As Outlook.Namespace, olTask As Outlook.TaskItem
    Set olApp = Outlook.Application
    Set olNs = olApp.GetNamespace("MAPI")
        olNs.Logon
    Set olTask = olApp.CreateItem(olTaskItem)
    olTask.Assign
    olTask.Subject = "Test"
    olTask.Body = "Testing macro"
    olTask.Recipients.Add ("myemail@myemail.com")
    olTask.Display
End Sub
 
Last edited by a moderator:
Very curious if anybody was able to figure this one out. I'm getting the same error in the exact same point and have scoured the web for a solution. The SendKeys thingy seems to be closest to a workable solution here but I'm losing sleep over this one - why, Excel, why!
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Well,

this is all well and good but apparently the SendKeys method is not great if you have multiple meeting requests (as have I ). The macro actually creates the meetings faster than the SendKeys types in the names. Of course, I can make the application wait but that's not very efficient. Any ideas are most welcome.

Very curious if anybody was able to figure this one out. I'm getting the same error in the exact same point and have scoured the web for a solution. The SendKeys thingy seems to be closest to a workable solution here but I'm losing sleep over this one - why, Excel, why!
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top