Excel to outlook without repeating tasks

Closed
Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Hello,

I am having a small problem. I want to use excel to update the tasks in outlook. All I have is a due date (from A2) and a task (from B2) Here is the code I have got so far

Code:
Sub UpdateTasks()


Dim olApp As Outlook.Application
Dim blnCreated As Boolean
Dim arrTasks() As Variant, I As Long
arrTasks = Range("A2", Cells(Rows.Count, "B").End(xlUp)).Value
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If olApp Is Nothing Then
Set olApp = CreateObject("Outlook.Application")
blnCreated = True
Err.Clear
Else
blnCreated = False
End If
On Error GoTo 0
For I = LBound(arrTasks) To UBound(arrTasks)
With olApp.CreateItem(olTaskItem)
.DueDate = arrTasks(i, 1)
.Subject = arrTasks(i, 2)
.Save
' .Close
End With
Next I
If blnCreated = True Then
olApp.Quit
End If
End Sub

Which is all working well. However, it doesn't recognize if a task already exists then don't re-enter it. Every time the Macro is ran, it is doing all the tasks over again, instead of just adding the new tasks.

I hope that make sense and im sure its an easy fix but im not a programming wiz. any help would be great as I need this asap

many thanks

2 replies

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
See this

http://www.codeforexcelandoutlook.com/blog/2008/08/export-outlook-tasks-to-excel/
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month

Might be a little bit backwards, but probably easiest to have Excel run a script first that has Outlook export its existing tasks to Outlook. Then have Excel de-dupe the tasks and send the new ones back to Outlook. I'm quite the programming newbie myself, so have no idea / code handy on how to get Outlook to send it's task list to Excel.