Creating and assigning Outlook tasks from Access

T

Todd Lemen

The following code in Access VBA:
Sub Experiment()
Dim myOlApp As Object
Dim myItem As Outlook.TaskItem
Dim myDelegate As Outlook.Recipient
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olTaskItem)
myItem.Assign
Set myDelegate = myItem.Recipients.Add("April LaMonte")
myItem.Subject = "Prepare Agenda For Meeting"
myItem.DueDate = #9/20/1997#
myItem.Display
End Sub

returns the following error at the "myItem.Assign" line:
***************
Runtime error '-2079309819{84104005}'
The task "" is stored as a file, not as an item in an
Outlook folder, so the requested action cannot be
performed.
**************

Huh?

Thanks,

TL
 
T

TC

This is an Outlook question, not an Access question. Check the Outlook VBA
online help for the Assign method of the Item object. Perhaps it needs a
parameter?

HTH,
TC
 
T

Todd Lemen

Actually, it is an Access question because exact same
code works fine in Outlook VBA. When the code is
activated in Access VBA, it generates the runtime error
indicated.
 
T

Todd Lemen

Issue resolved. Save an Outlook item before assigning
it. Otherwise, Outlook views the item as a "file" rather
than an Outlook item, and generates the runtime error.

Here is the procedure:
Sub Experiment()
Dim myOlApp As Object
Dim myItem As Outlook.TaskItem
Dim myDelegate As Outlook.Recipients
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olTaskItem)
Set myDelegate = myItem.Recipients.Add("April LaMonte")
myItem.Subject = "Prepare Agenda For Meeting"
myItem.DueDate = #9/20/1997#
myItem.Save
myItem.Assign
myItem.Display
End Sub

TL
 
T

TC

Soundls like an >Outlook< issue to me!

TC :)


Todd Lemen said:
Issue resolved. Save an Outlook item before assigning
it. Otherwise, Outlook views the item as a "file" rather
than an Outlook item, and generates the runtime error.

Here is the procedure:
Sub Experiment()
Dim myOlApp As Object
Dim myItem As Outlook.TaskItem
Dim myDelegate As Outlook.Recipients
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olTaskItem)
Set myDelegate = myItem.Recipients.Add("April LaMonte")
myItem.Subject = "Prepare Agenda For Meeting"
myItem.DueDate = #9/20/1997#
myItem.Save
myItem.Assign
myItem.Display
End Sub

TL
 

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