Protecting Baseline Fields


Baseline refers to approved estimates. After you have set the baseline in Project, the approved estimates can be displayed by inserting the Baseline fields such as Baseline Start, Baseline Finish, Baseline Work, Baseline Cost and Baseline Duration. Depending on the view these columns are inserted, Project can either display the approved estimates of tasks, resources or assignments

In Gantt Chart view, you can see the approved estimates of the tasks

In Task Usage view, you can see the approved estimates of tasks as well as its assignments

In Resource Sheet view, you can see the approved estimates of resources

Project does not have feature to lock the approved estimates. You can change the baseline fields and Project doesn’t stop you from doing that.

A better solution is capture the event and having VBA handlers for it.

1. Click View tab. Click Macros dropdown and select Visual Basic
image12.png?w=640

2. In the Visual Basic Editor, on the option menu for VBAProject, choose Insert, and then choose Class Module to create a class named Class1.

3. You can rename the class module in the Properties pane. In the following examples, the class is named Events.

4. You must create a new object using the WithEvents keyword in a class module
Public WithEvents App As Application
5. If you user changes the task related fields, the event ProjectBeforeTaskChange is fired. So, change the object and procedure to App and ProjectBeforeTaskChange respectively

6. If you user changes the assignment related fields, the event ProjectBeforeAssignmentChange is fired. So, change the object and procedure to App and ProjectBeforeAssignmentChange respectively

7. If you user changes the resource related fields, the event ProjectBeforeResourceChange is fired. So, change the object and procedure to App and ProjectBeforeResourceChange respectively

8. You need to bind the current Application object to the App object declared in the class to fire the events. Open the ThisProject module and paste the below code. This code declares an object X of type Events (the class module we created earlier), and sets the current Application object to the App object of Events class module

8. Save the changes.
10. Save the plan and close Project.

Now, reopen the plan (why? the application object is set in Project_Open event handler) and make change to the baseline fields. Project will not accept the change and you need to press Escape key to cancel the edit

What are you starting now?


I recently came across this interesting question from Algola in MPUG Discussion Forum

http://www.mpug.com/forums/topic/filter-activities-that-can-start/

In other words, the solution should work for the below scenarios
Scenario 1: Unstarted tasks without any predecessors

Scenario 2: Unstarted tasks with all predecessors 100% complete

Let me demonstrate how this can be done using VBA Macros

1. Click View tab. Click Macros dropdown and select Visual Basic

image12.png?w=640

2. In the editor, double click your current project on the left panel. This will display the code editor.
3. Now, insert a procedure named ReadyToStart by selecting Insert menu, and then Procedure.

4. Inside the ReadyToStart procedure, write this code to loop through all the tasks in the current project

5. We will now use the Marked field to indicate whether the task is ready to start or not. If the current task is not yet started, set Marked to True otherwise False

6. If the current task is not yet started then check if predecessors, if any, are completed or not

7. After marking the tasks, we will now highlight these tasks by creating a filter Ready To Start

The complete code is shown below

8. Now to run this macro click View tab. Click Macros dropdown and select View Macros. Select the macro ReadyToStart and click Run button

I Know What You Did Last Summer


This post is not about the horror movie but about “I Know What You Did Last Update”

i-know-what-you-did-last-summer.jpg

Project 2013 includes Created field to tell the date and time when the task or resource was added to your plan

In Gantt Chart view …

In Resource Sheet view …

Every time you update your plan, you lose track of which ones you updated. The problem is Project doesn’t have a field to tell when the task is last updated.

You need to write a small VBA to code to handle this requirement. We will be using a custom date field (Date1) to store the current date and time when the task is updated and here is how it goes.

1. Click View tab. Click Macros dropdown and select Visual Basic
image12.png?w=640

2. In the Visual Basic Editor, on the option menu for VBAProject, choose Insert, and then choose Class Module to create a class named Class1.

3. You can rename the class module in the Properties pane. In the following examples, the class is named Events.

4. You must create a new object using the WithEvents keyword in a class module
Public WithEvents App As Application
5. Now change the object and procedure to “App” and “ProjectBeforeTaskChange”. ProjectBeforeTaskChange event will be fired for every task that is changed
Capture

6. Within this sub-routine include the below code

7. You need to bind the current Application object to the App object declared in the class to fire the events. Open the ThisProject module and paste the below code. This code declares an object X of type Events (the class module we created earlier), and sets the current Application object to the App object of Events class module

8. Save the changes.
9. Insert Date1 column in Gantt Chart. Right the column and select Custom Fields. In Custom Fields dialog, rename Date1 to Modified

10. Save the plan and close Project.

Now, reopen the plan (why? the application object is set in Project_Open event handler) and make some changes the tasks. You will notice the Modified column will get updated to current date and time

Your Personal Assistant: Project can remind the tasks due this week


In my earliest post, you learnt how to write event procedures for Project and Application object. In this post, I will focus on a very simple tip – "How to highlight the tasks due this week every time the project plan is opened?".

Looks very simple and it is indeed very simple.

1. Click View tab. Click Macros dropdown and select Visual Basic
image12.png?w=640

2. In the editor, double click your current project on the left panel.

3. Now change the object and procedure to "Project" and "Open".

4. This will include a private sub-routine which will be invoked when the file is opened

5. Within this sub-routine, include the below script

6. Close the editor, and close the project

Open the project file, and Project will highlight the incomplete tasks that should be completed by this week.

Stop! Don’t delete approved tasks


In my earliest post, you learnt about how to use Calculate Event procedure in the Project object to color tasks with no dependencies set. The events of Project are available for any open project – reference http://msdn.microsoft.com/en-us/library/office/dn217671(v=office.15).aspx

You have a more powerful object called Application. It represents the entire Project application. To write event procedures for the Application object, you must follow a new approach.

Let’s take an example to illustrate Application object’s event procedure. As a best practice, it is advisable not to delete baseline tasks since you will lose the evidence and will have incorrect variance. It is hence recommended to Inactivate the task (see this blog about the benefits).

Design and Build tasks is approved and Test task is inserted later.

After deleting Build task, you lost the proof that Build was part of your plan

The following steps will guide you how to create event handler before a task is deleted

1. Click View tab. Click Macros dropdown and select Visual Basic
image12.png?w=640

2. In the Visual Basic Editor, on the option menu for VBAProject, choose Insert, and then choose Class Module to create a class named Class1.

3. You can rename the class module in the Properties pane. In the following examples, the class is named Events.

4. You must create a new object using the WithEvents keyword in a class module
Public WithEvents App As Application
5. Now change the object and procedure to "App" and "ProjectBeforeTaskDelete". ProjectBeforeTaskDelete event will be fired for every task that is deleted.

6. Within this sub-routine include the below code

7. You need to bind the current Application object to the App object declared in the class to fire the events. Open the ThisProject module and paste the below code. This code declares an object X of type Events (the class module we created earlier), and sets the current Application object to the App object of Events class module

The code displays the message "Dont’ delete baseline task. Instead Inactivate the task" and cancels the delete action if the Baseline Start of the task deleted is set.

Get alerted when tasks have no dependencies set


In my previous blog post "Highlight items after every change", you have learnt how to apply highlight the tasks after every change by using Visual Basic for Applications macro.

Best practice followed when linking tasks is (a) Don’t link summary tasks to summary task – as it complicates the scheduling logic, (b) Every other task should have at least one predecessor or successor task.

It is easy to validate the above provide your plan is small (this is quite relative again 🙂 ). In this blog post, I will walk through on how VBA macros can color tasks automatically with no dependencies set and color summary tasks with dependencies set.

In the above plan, you can notice I have violate the first rule (a) Phase 1 (task id 1) is linked to Phase 2 (task id 4), (b) Go Live (task id 7) is not linked to any other tasks

Let’s start with a pseudocode for this requirement.

1. For each task in plan do
1.1. If task is not empty and active
1.1.1. If the task is summary task
1.1.1.1. If number of dependencies is greater than zero, then mark it.
1.1.2. If the task is not summary task
1.1.2.1. If number of dependencies is zero, then mark it
2. Color the marked task

Now you need to translate each statement by using Project model object, properties and methods.

1. Click View tab. Click Macros dropdown and select Visual Basic
image12.png?w=640

2. In the editor, double click your current project on the left panel.
3. Now change the object and procedure to "Project" and "Calculate".

4. This will include a private sub-routine which will be invoked automatically after calculation!!

5. Within this sub-routine, include the below script

The above sub-routine checks if the current view is Gantt Chart. Then, it changes the text styles of marked tasks (Item:=5) to default color. Then, we loop through the task list and mark the tasks having the issues.

After closing the editor, I just retyped a task information and Project automatically colors the task that need attention in red.

Highlight items after every change


Project 2013 gives features to highlight, filter and group tasks on certain conditions. These commands are available in View ribbon.

I have selected the criteria "Critical" in Highlight list, and Project highlights the critical tasks with yellow background color.

Wonderful!!

Now, I changed the duration of Build 2 to 4 days. This task doesn’t get highlighted though it is part of the critical path. Why?

After selecting the criteria, Project applies it only once in the current view. In other words, Project doesn’t refresh the view after every change.

You need to write a small script that will be apply the filter after every change, and this is quite simple.

1. Click View tab. Click Macros dropdown and select Visual Basic

2. In the editor, double click your current project on the left panel.
3. Now change the object and procedure to "Project" and "Change".

4. This will include a private sub-routine which will be invoked automatically after every edit!!

5. Within the sub-routine, include the below script. This code applies the Critical filter if the current view is "Gantt Chart"
If pj.CurrentView = "Gantt Chart" Then
FilterApply Name:="Critical", Highlight:=True
End If

6. Close the editor.

Now, I changed the duration of Build 2 to 5 days and Project automatically highlights the critical tasks 🙂