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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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,214,821
Messages
6,121,759
Members
449,048
Latest member
excelknuckles

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