Hello everybody,
I am using Excel 2013 and Windows 10 software. I have found then used macros that allow me to create Outlook tasks from Excel, but I need help building one that will allow me to update those tasks when needed. Below is the code that I modified to fit my needs after taking it from Automating Tasks. It runs without any error, but it does not update the task in Outlook. Any suggestions? Thank you all in advance for your help and time, I hope I am complying with all of the guidelines for posting.
I am using Excel 2013 and Windows 10 software. I have found then used macros that allow me to create Outlook tasks from Excel, but I need help building one that will allow me to update those tasks when needed. Below is the code that I modified to fit my needs after taking it from Automating Tasks. It runs without any error, but it does not update the task in Outlook. Any suggestions? Thank you all in advance for your help and time, I hope I am complying with all of the guidelines for posting.
Code:
Sub Get_And_Change_Task()
Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olTsk As TaskItem
Dim new_start As String, new_end As String, subject As String
subject = InputBox("Type the name of the activity you wish to make changes to:")
new_start = InputBox("Enter new start date:")
new_end = InputBox("Enter new end date:")
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderTasks)
For Each olTsk In Fldr.Items
If olTsk.subject = subject Then
olTsk.StartDate = CDate(new_start)
olTsk.DueDate = CDate(new_end)
End If
Next olTsk
Set olTsk = Nothing
Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing
End Sub