It worked on my machine, but I set a reference to the Outlook object
library. You should consider rewriting your code to take advantage of
this. For example:
Dim oApp As Outlook.Application ' not Object
Dim objTask As Outlook.TaskItem ' not Obect
Set oApp = New Outlook.Application ' early binding
Set objTask = oApp.CreateItem(olTaskItem)
With objTask
.Subject = "Test"
.Body = "Test"
.DueDate = DateValue("06/26/03")
.Startdate = DateValue("06/26/03")
.Send
.Close olSave ' I believe this is moot as the item is already
closed/sent
End With
Set objTask = Nothing
Set oApp = Nothing
End Sub
You would need to set a reference to the Microsoft Outlook Object
Library by going to Tools>References in the VB Editor and locating the
appropriate OL. For example if you were using Office 2003, then it
would be "Microsoft Outlook 11.0 Object Library".
HTH,
JP
> Hi JP,
>
[quoted text clipped - 42 lines]
>
> - Show quoted text -
Albert - 23 Jan 2008 19:15 GMT
Hi JP,
I have changed the reference in VB tools and the code:
Sub CreateTask()
Dim oApp As Outlook.Application ' not Object
Dim objTask As Outlook.taskItem ' not Obect
Set oApp = New Outlook.Application ' early binding
Set objTask = oApp.CreateItem(olTaskItem)
With objTask
.Subject = "Test"
.Body = "Test"
.DueDate = DTPickerTaskduedate.Value 'DateValue("06/26/03")
.Startdate = DTPicker1.Value 'DateValue("06/26/03")
.Send
End With
Set objTask = Nothing
Set oApp = Nothing
End Sub
I am using office 12. I now get a error "you cannot send this task because
it is not in a valid state. Use the assign method first"
Any ideas?
Thanks
A
> It worked on my machine, but I set a reference to the Outlook object
> library. You should consider rewriting your code to take advantage of
[quoted text clipped - 73 lines]
> >
> > - Show quoted text -
JP - 23 Jan 2008 19:49 GMT
Is that Outlook 2007? I'm not familiar with that version. You might
want to repost your last message as a new topic, and be sure to
specify the version of Outlook.
Also you mentioned that you were running this from a command button on
a userform, if so shouldn't the Sub line be something like "Sub
CommandButton1_click()" ?
Sorry I couldn't be more help here.
--JP
> Hi JP,
>
[quoted text clipped - 105 lines]
>
> - Show quoted text -