Create Task in Outlook from Excel VBA

Jgordon

New Member
Joined
Apr 4, 2018
Messages
13
Hello Everyone,

I'm trying to create a task in Outlook from Excel. I've gotten pretty far in this code but I'm stuck with the start date.

Let me know your thoughts
Code:
Sub tasks()

Dim OutApp As Object
Dim myItem As Object
Dim Body1 As String






Const myTitle = "Enter data"
    myPrompt = "Task content" & Chr(13) & "(describe what needs to be done)"
    
    Body1 = InputBox(myPrompt, myTitle)




Set OutApp = CreateObject("Outlook.Application")
Set myItem = OutApp.CreateItem(olTaskItem)


    With myItem
       .StartDate = Now
       .Subject = Selection.Cells(3) & Selection.Cells(5)
       .DueDate = .StartDate + 1
       .ReminderTime = .DueDate - 1
       .Body = Body1
       .Assign
       .Display
    End With


Set myItem = Nothing
Set OutApp = Nothing


End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
How are you stuck?

Is not accepting Now? Is it creating the task on the wrong date/time?
 
Upvote 0
Yes. I’m worried that the task date needs to be formatted a particular way. Does that make sense?
 
Upvote 0
So, is the task being created but for the wrong date/time?

PS Where are you setting the value of olTaskItem?
 
Upvote 0
It is not creating the task at all. I run the code and it gets stuck on the Startdate

I have not set the value of the olTaskItem do you think there is an issue there?
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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