Create new project action macro

A couple of macros I use to create a new next action in the same project and subproject (new release of Netcentric GTD toolkit)....

Function GetProjectName() As String

Dim itmTask As Outlook.TaskItem
Dim objProperty As UserProperty
Dim projectName As String
Dim i As Integer

If ActiveInspector.CurrentItem.Class = 48 Then
Set itmTask = ActiveInspector.CurrentItem
GetProjectName = ""

Set objProperty = itmTask.UserProperties.Find("Project")

If Not objProperty Is Nothing Then
GetProjectName = itmTask.UserProperties("Project")
End If
End If

GotTheProjectName:
End Function
Function GetSubprojectName() As String

Dim itmTask As Outlook.TaskItem
Dim objProperty As UserProperty
'Dim subprojectName As String
Dim i As Integer

If ActiveInspector.CurrentItem.Class = 48 Then
Set itmTask = ActiveInspector.CurrentItem
GetSubprojectName = ""

Set objProperty = itmTask.UserProperties.Find("Subproject")

If Not objProperty Is Nothing Then
GetSubprojectName = itmTask.UserProperties("Subproject")
End If
End If

GotTheProjectName:
End Function

Function FindProjectFolder() As String
On Error GoTo Err_FindProjectFolder

Dim projectName As String

FindProjectFolder = ExplorerProjectFolderPath

projectName = GetProjectName()

If projectName = "" Then
MsgBox ("This task is not part of a GTD project.")
GoTo Exit_FindProjectFolder

End If

FindProjectFolder = FindProjectFolder & projectName

Exit_FindProjectFolder:
Exit Function

Err_FindProjectFolder:
MsgBox Err.Description
Resume Exit_FindProjectFolder

End Function

Sub newProjectTask()

On Error GoTo Err_NewProjectTask

Dim objApp As Outlook.Application
Dim itmTask As Outlook.TaskItem
Dim newProjectTask As Outlook.TaskItem
Dim projectName As String
Dim subprojectName As String

projectName = GetProjectName()
subprojectName = GetSubprojectName()

If projectName = "" Then
MsgBox ("This task is not part of a project!")
GoTo Exit_NewProjectTask
End If

Set objApp = CreateObject("Outlook.Application")
Set newProjectTask = objApp.CreateItem(olTaskItem)

With newProjectTask
newProjectTask.UserProperties.Add("Project", olText) = projectName
newProjectTask.UserProperties.Add("Subproject", olText) = subprojectName
newProjectTask.UserProperties.Add("GettingThingsDone", olYesNo) = 1
newProjectTask.Display
End With

Exit_NewProjectTask:
Set itmTask = Nothing
Exit Sub

Err_NewProjectTask:
MsgBox Err.Description
Resume Exit_NewProjectTask

End Sub

Just paste these into a macro file in outlook and create a custom toolbar in a outlook task item, and they should work fine. I use this a lot...

Roger
 
Interesting...

This is interesting...but for us folk who may not be familiar with how to set up these macros, how might use this information...par chance?

Thanks,

Bob
 
This Macro Rocks!!!!!

This macro gets around a serious problem in the 2.1 GTD Outlook add in. With the add in, if you select the next action for a project, the previous one is marked complete -- a feature for some, a problem for me. I like to list out a bunch of tasks and build a mini-project plan or task list in each project. I can do that by creating the next task with this macro. For those that are Macro impared, here is how to implement it.

1. In Outlook select Tools|Macro|Macro and type a new name in the "Macro Name" box. Then, click on the "Create" button.

2. If, you are like most people and have no macros defined, you can select the text in the default VBA module and paste over the code from the top of this thread. If you have other macros, select Insert|Module from the tool bar to get an empty module to use.

3. Once you have pasted the code into a module, then save the module by using File|Save from the menu bar.

4. Open a task. Right click the tool bar area to get the tool bar menu and select Customize. In the customize dialog box select the Toolbar tab and click on the "New" button. Type in an appropriate name like "NewProjectTask" for the tool bar and click "OK" button.

5. A new toolbar will appear somewhere on the task. Drag it to the tool bar area to dock it. The right click on the new toolbar, and select Customize. In the "Commands" tab select Macros on the left side of the dialog box. You should see your module icon. Drag it to the new toolbar that you created.

Now you are all set to use the macro to create new project tasks without having the previous one marked complete.
 
Alchemist:

I'm glad you like that macro.

A comment, though. You said that with the add-in v2.1 when you add the next task it marks the previous one complete. I have the add-in, v 2.1.33 and it does not do that for me (or should I say 'to' me:). When I click the "New Project Task" button on the toolbar, I get a new task form with the project field pre-filled in, and the Action field blank. The previous, uncomplete task stays just the way it was.

Thought you might want to know...
 
One question, how would you mofify this macro to work if you no longer use the Outlook add-in, but have created custom fields (Projects, SubProjects)?

Lars
 
Top