Hello all,
I would like to create Outlook reminders based on task due dates in a specific column (in some instances there will be no date).
I managed to create a code that works based on pieces of code found in other threads and my own. The code works perfectly and does what I want it to do but it relies on the entry id and my only issue is that I don't find the entryid output in column D very elegant and instead of having the entryid value entered in column D, I would like to only have the words "created" after a reminder is created. The ideal code would create a reminder if there is a date present in column C and if the corresponding value in column D is blank (to prevent duplicates). The macro will be run multiple times since the file will constantly be updated with new task and dates.
Thanks for your time and help!
Regards,
Ellie
I would like to create Outlook reminders based on task due dates in a specific column (in some instances there will be no date).
I managed to create a code that works based on pieces of code found in other threads and my own. The code works perfectly and does what I want it to do but it relies on the entry id and my only issue is that I don't find the entryid output in column D very elegant and instead of having the entryid value entered in column D, I would like to only have the words "created" after a reminder is created. The ideal code would create a reminder if there is a date present in column C and if the corresponding value in column D is blank (to prevent duplicates). The macro will be run multiple times since the file will constantly be updated with new task and dates.
VBA Code:
Sub New_Attempt()
Dim rng As Range
Dim Dtrng As Range
Dim strEntryID As String
Dim olkAppt As Object
Static olkApp As Object
Const olAppointmentItem As Integer = 1
Dim LastRow As Long
Application.EnableEvents = False
LastRow = Cells(Rows.Count, "C").End(xlUp).Row
Set rng = Range("C2:C" & LastRow)
If rng Is Nothing Then Exit Sub
If olkApp Is Nothing Then Set olkApp = CreateObject("outlook.application")
For Each Dtrng In rng
If Dtrng.Value <> "" Then
Select Case Dtrng.Column
Case Columns("C").Column
strEntryID = Range("D" & Dtrng.Row)
Case Else
Application.EnableEvents = True
Exit Sub
End Select
If strEntryID <> "" Then
On Error Resume Next
Set olkAppt = olkApp.session.getitemfromid(strEntryID)
On Error GoTo 0
End If
If olkAppt Is Nothing Then Set olkAppt = olkApp.CreateItem(olAppointmentItem)
With olkAppt
.Start = Range("C" & Dtrng.Row)
.Duration = 30
.Subject = "Complete " & Range("A" & Dtrng.Row)
.Body = "Complete " & Range("A" & Dtrng.Row) & " Start date: " & Range("B" & Dtrng.Row)
.reminderminutesbeforestart = 15
.BusyStatus = 5
.reminderset = True
.Save
Select Case Dtrng.Column
Case Columns("C").Column
Range("D" & Dtrng.Row) = .entryid
End Select
End With
End If
Set olkAppt = Nothing
Next
Application.EnableEvents = True
MsgBox "Reminder(s) created"
End Sub
Thanks for your time and help!
Regards,
Ellie