Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Create an Outlook Task

I want to set up a task through excel.
I get an error:
User defined type not defined on the objTask As Outlook.TaskItem
on the following.

Sub createTask()
Dim objTask As Outlook.TaskItem
Set objTask = OutApp.CreateItem(olTaskItem)
With objTask
.StartDate = "05/30/2008"
.DueDate = "05/31/2008"
.Subject = "Testing Task"
.Body = "Testing Task"
.Assign
.Recipients = "Employee Name"
.Send
End With
Set objTask = Nothing
End Sub


How do I correct this?

Thank you,

Steven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Create an Outlook Task

Steven,

I've had better luck grabbing the Tasks folder and then using the 'add'
method of the 'items' collection. The sample below is a routine I use to
create multiple tasks.

' _________________________________

Sub LoadTasks()

Const olFolderTasks = 13

Dim r As Integer
Dim x As Integer

r = Range("A65536").End(xlUp).Row

Set ol = CreateObject("Outlook.Application")
Set ns = ol.GetNamespace("MAPI")
Set olFolder = ns.GetDefaultFolder(olFolderTasks)

For x = 1 To r
Set taskItem = olFolder.Items.Add
With taskItem
.Subject = Sheets("Sheet1").Cells(x, 1).Value
.DueDate = Sheets("Sheet1").Cells(x, 2).Value
.Save
End With
Next x

Set taskItem = Nothing
Set ns = Nothing
Set ol = Nothing

End Sub

'________________________________

Steve Yandl



"Steven" wrote in message
...
I want to set up a task through excel.
I get an error:
User defined type not defined on the objTask As Outlook.TaskItem
on the following.

Sub createTask()
Dim objTask As Outlook.TaskItem
Set objTask = OutApp.CreateItem(olTaskItem)
With objTask
.StartDate = "05/30/2008"
.DueDate = "05/31/2008"
.Subject = "Testing Task"
.Body = "Testing Task"
.Assign
.Recipients = "Employee Name"
.Send
End With
Set objTask = Nothing
End Sub


How do I correct this?

Thank you,

Steven



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Create an Outlook Task

Hi Steven,

In the vbe under tools, is the reference set to Microsoft Outlook 9.0
Object Library?

Dan
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Create an Outlook Task

Hi Steve,

When I tried the code sample

I had to dim ol and ns

so I did it like this:
Const olFolderTasks = 13

Dim ol As Application
Dim ns As NameSpace
Dim r As Integer
Dim x As Integer

Excel returned the compile error: Assignment to a constant not
permitted on

Set olFolder = ns.GetDefaultFolder(olFolderTasks)

Should I have done something differently?

Dan
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Create an Outlook Task

Having to dim ol and ns doesn't surprise me, you probably have 'option
explicit' set (I probably should as well). I'm not sure why you're not
allowed to use the constant to grab the 'Tasks' folder. I'm running Office
2003, perhaps this is a version issue????

Steve


"dan dungan" wrote in message
...
Hi Steve,

When I tried the code sample

I had to dim ol and ns

so I did it like this:
Const olFolderTasks = 13

Dim ol As Application
Dim ns As NameSpace
Dim r As Integer
Dim x As Integer

Excel returned the compile error: Assignment to a constant not
permitted on

Set olFolder = ns.GetDefaultFolder(olFolderTasks)

Should I have done something differently?

Dan





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Create an Outlook Task

Hi Steve,

I'm using Excel 2000. That probably explains it.

Thanks,

Dan
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
create outlook task from excel Albert Excel Programming 1 January 23rd 08 09:44 PM
Create Outlook Task from Data in Excel Row Theresa Excel Programming 0 October 20th 05 01:57 AM
Can I create a button in Excel that generates a task in Outlook? Tio777 Excel Discussion (Misc queries) 1 June 15th 05 03:41 PM
Create Outlook task from Excel Macro? Jay Harris Excel Programming 4 February 25th 05 08:33 PM


All times are GMT +1. The time now is 02:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"