Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / July 2007

Tip: Looking for answers? Try searching our database.

Mass changing Task Due Dates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 11 Jul 2007 13:50 GMT
Is there a way to mass change task due dates?

I generally have several tasks due today. However, I may only fully complete
one or two of them. I want to mass change the others so that they are changed
to the next day, next week, etc., without going into each one individually.

I can't find any standard functionality for this. VBA may be my best hope,
but I am not sure how to program this in Outlook. I am experienced with VBA
in Excel, but not in Outlook.

Thanks!
Eric Legault [MVP - Outlook] - 11 Jul 2007 17:20 GMT
Try this code:

Sub RecurseTasks()
On Error GoTo RecurseTasks_Error

Dim objOL As Outlook.Application
   Dim objNS As Outlook.NameSpace
   Dim objTasksFolder As Outlook.MAPIFolder
   Dim objItems As Outlook.Items
   Dim objTaskItem As Outlook.TaskItem
   
   Set objOL = New Outlook.Application
   Set objNS = objOL.GetNamespace("MAPI")
   Set objTasksFolder = objNS.GetDefaultFolder(olFolderTasks)
   'Set objItems = objTasksFolder.Items.Restrict("[Due Date] >= '" &
Format(Date, "ddddd h:nn AMPM") & "'")
   Set objItems = objTasksFolder.Items.Restrict("[Due Date] >= '" &
Format(Date, "ddddd") & "'")
   
   For Each objTaskItem In objItems
       Debug.Print objTaskItem.Subject & " (Start: " &
objTaskItem.startDate & "; End: " & objTaskItem.DueDate
       'or edit task:
'        objTaskItem.DueDate = #8/31/2007#
'        objTaskItem.Save
   Next
   
   Set objOL = Nothing
   Set objNS = Nothing
   Set objTasksFolder = Nothing
   Set objTaskItem = Nothing
   Set objItems = Nothing

   On Error GoTo 0
   Exit Sub

RecurseTasks_Error:

   MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
RecurseTasks of Module basTasksMacros"
   Resume Next
End Sub

Signature

Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/

> Is there a way to mass change task due dates?
>
[quoted text clipped - 7 lines]
>
> Thanks!
Mike - 17 Jul 2007 13:32 GMT
Thanks. Here is a small update to the code. It works!

Also, I want to make these small improvements. Any ideas?
1. Only change the tasks I selected
2. Have pop-up box to either choose: Today or a Manually Entered Date.

Cheers!

Here is my updated code!

Sub UpdateTask_DueDate()
'Purpose: To update old tasks (with old Due Dates) to Today

On Error GoTo RecurseTasks_Error

Dim objOL As Outlook.Application
   Dim objNS As Outlook.NameSpace
   Dim objTasksFolder As Outlook.MAPIFolder
   Dim objItems As Outlook.Items
   Dim objTaskItem As Outlook.TaskItem
   
   Set objOL = New Outlook.Application
   Set objNS = objOL.GetNamespace("MAPI")
   Set objTasksFolder = objNS.GetDefaultFolder(olFolderTasks)
   Set objItems = objTasksFolder.Items.Restrict("[Due Date] < '" &
Format(Date, "ddddd") & "'")
   
   For Each objTaskItem In objItems
'        Debug.Print objTaskItem.Subject & " (Start: " &
objTaskItem.StartDate & "; End: " & objTaskItem.DueDate
       'or edit task:
       objTaskItem.DueDate = Date
'        objTaskItem.DueDate = #8/31/2007#
       objTaskItem.Save
   Next
   
   Set objOL = Nothing
   Set objNS = Nothing
   Set objTasksFolder = Nothing
   Set objTaskItem = Nothing
   Set objItems = Nothing

   On Error GoTo 0
   Exit Sub

RecurseTasks_Error:

   MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
RecurseTasks of Module basTasksMacros"
   Resume Next
End Sub



> Try this code:
>
[quoted text clipped - 50 lines]
> >
> > Thanks!
Eric Legault [MVP - Outlook] - 17 Jul 2007 16:10 GMT
Look to the Explorer.Selection object to give you a collection of items that
are selected in the active folder.

For full control over presenting the user with options, design a UserForm
with your custom UI.  Otherwise, for simplicity you can use VBA's InputBox
function to prompt for a value (you can provide a default value for the user
as well).

Signature

Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/

> Thanks. Here is a small update to the code. It works!
>
[quoted text clipped - 104 lines]
> > >
> > > Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.