Project: Macro to Display Work Progress in Gantt Chart |
Q126389
Using Microsoft Project, you can use a macro to create a custom Gantt
bar whose length is calculated as a percentage of a different task bar.
This macro can be useful for displaying different types of progress
information on a task that is not normally available in Gantt bar form.
For example, although Microsoft Project does not provide a standard Gantt
bar that represents the percentage of work performed on a task, you can
create such a bar by modifying the Gantt Chart and creating a custom macro.
The default Gantt Chart in Microsoft Project includes a Progress bar which
visually represents the % Complete of a given task, which is based on the
task's duration. However, there is no direct way to create a corresponding
Work Progress bar to represent the % Work Complete of a given task.
However, you can use a Visual Basic macro to create such a bar.
In order to create a custom bar in the Gantt chart, you must specify two
date fields between which the bar should be drawn. For the Work Progress
bar, these two fields will be Start and Start5. The Start5 field will be
calculated by the macro in such a way that the length of this bar
accurately represents the % Work Complete of the task.
Before you create the custom macro, add the new bar definition to your
Gantt Chart by following these steps:
Name Show For...Tasks Row From To
---------------------------------------------------------
Work Progress Normal 1 Start Start5
Select a style for the bar using the options on the Bar tab at
the bottom of the Bar Styles dialog.
Sub CalcWorkProgress()
Dim tskIndex As Task
Dim dWorkLen As Double
Dim dTaskLen As Double
For Each tskIndex In ActiveProject.Tasks
If Not (tskIndex Is Nothing) Then
' Get length of normal task bar in elapsed days.
dTaskLen = tskIndex.Finish - tskIndex.Start
' Calc length of Work Progress bar in elapsed days.
dWorkLen = tskIndex.PercentWorkComplete / 100 * dTaskLen
' Calc a date corresponding to this bar length.
tskIndex.Start5 = tskIndex.Start + dWorkLen
End If
Next tskIndex
End Sub Additional query words:
Keywords :
Issue type : kbinfo
Technology : kbHWMAC kbOSMAC kbProjectSearch kbProject400Mac kbProjectMacSearch kbProject400
|
Last Reviewed: November 5, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |