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
On Jan 23, 2:15*pm, Albert <Alb...@discussions.microsoft.com> wrote:
> 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
>
>
>
> "JP" wrote:
> > 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
>
> > On Jan 23, 2:44 am, Albert <Alb...@discussions.microsoft.com> wrote:
> > > Hi JP,
>
> > > Thanks for the response, but I still get the same error "Object does not
> > > support the object or method" at the "duedate".
>
> > > Albert
>
> > > "JP" wrote:
> > > > It should be "Set objTask = oApp.CreateItem(olTaskItem)"
>
> > > > "olFolderTasks" is the constant for the default Tasks folder.
>
> > > > HTH,
> > > > JP
>
> > > > On Jan 22, 9:04 pm, Albert <Alb...@discussions.microsoft.com> wrote:
> > > > > Hi guys,
>
> > > > > I am trying to create a task from a commandbutton in a userform.
> > > > > This is what I got so far:
> > > > > Sub CreateTask()
>
> > > > > Dim oApp As Object
> > > > > Set oApp = CreateObject("Outlook.Application")
>
> > > > > Dim objTask As Object
>
> > > > > Set objTask = oApp.CreateItem(olFolderTasks)
> > > > > With objTask
> > > > > * * .Subject = "Test"
> > > > > * * .Body = "Test"
> > > > > * * .DueDate = DateValue("06/26/03")
> > > > > * * .Startdate = DateValue("06/26/03")
> > > > > * * .Send
> > > > > * * .Close olSave
> > > > > End With
> > > > > Set objTask = Nothing
> > > > > End Sub
>
> > > > > Obviously it is not working as I get a runtime error "Object does not
> > > > > support the object or method" at the "duedate.
>
> > > > > Can anyone help me with the correct code?
>
> > > > > Thanks
> > > > > Albert- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
|