BizTalk Blog by Chris Han

BizTalk, ASP.NET, C#, SQL server, Visual studio

  Home  |   Contact  |   Syndication    |   Login
  63 Posts | 9 Stories | 87 Comments | 82 Trackbacks

News

Article Categories

Archives

Post Categories

Image Galleries

BizTalk Bloggers

BizTalk on MSDN

Patterns & Architecture

SharePoint

I was working a project schedule with MS project. I started by estimate the duration in 'months' using PERT, and later I decided to switch to 'days'. The I run into the duration format convertion trouble. I fund the set the 'Duration is entered in' drop down list in option menu didn't really do the job.

Then I fund this 'Format_Duration' Macro in  tool-macro menu. It works perfectly on Duration field. But not for the Optimistic duration, Expected duration, Pessimistic duration in PERT analysis. So I decided go into its VBS code and make a little change. The key is that "Optimistic duration, Expected duration, Pessimistic duration" are actually the alias to the real objects in Project object model. Their realy names are duration1, duration2, and duration3 in respective order.

Here is the VBS code will do. You need to find this Private Sub FormatTasks from the code behind the VB form named 'frmFormatDuration' and replace with the code below:

Private Sub FormatTasks(PrevProject As Project)
   
    Dim tskTask As Task
    Dim strDurationTemp As String
    Dim strDurationTemp1 As String
    Dim strDurationTemp2 As String
    Dim strDurationTemp3 As String
    Dim blnEstimated As Boolean
   
    
    'Set duration for each task
    'note that summary tasks get handled by the Tools.Options setting
    For Each tskTask In ActiveProject.Tasks
        If Not (tskTask Is Nothing) Then                    'Blank Task
            If Not tskTask.ExternalTask Then
                    If IsElapsedDuration(tskTask.GetField(pjTaskDuration)) Then
                        strDurationTemp = DurationFormat(tskTask.Duration, mintDurationElapsedUnits)
                        strDurationTemp1 = DurationFormat(tskTask.Duration1, mintDurationElapsedUnits)
                        strDurationTemp2 = DurationFormat(tskTask.Duration2, mintDurationElapsedUnits)
                        strDurationTemp3 = DurationFormat(tskTask.Duration3, mintDurationElapsedUnits)
                    Else
                        strDurationTemp = DurationFormat(tskTask.Duration, mintDurationUnits)
                        strDurationTemp1 = DurationFormat(tskTask.Duration1, mintDurationUnits)
                        strDurationTemp2 = DurationFormat(tskTask.Duration2, mintDurationUnits)
                        strDurationTemp3 = DurationFormat(tskTask.Duration3, mintDurationUnits)
                    End If
                If Not tskTask.Summary Then                     'not a Summary Task
                    blnEstimated = tskTask.Estimated
                    tskTask.Duration = strDurationTemp
                    tskTask.Duration1 = strDurationTemp1
                    tskTask.Duration2 = strDurationTemp2
                    tskTask.Duration3 = strDurationTemp3
                    tskTask.Estimated = blnEstimated
                Else            'task is a summary task
                    'check to see if it is an inserted project summary task
                    'if so, then display message for user indicating that we can't
                    'change the default settings (and thus summary tasks durations)
                    'for inserted projects
                    If tskTask.SubProject <> "" Then    'we have an inserted project
                        MsgBox tskTask.Name & MB_INSERTEDPROJ, R_TO_L, Title:=Application.Name
                    Else
                    tskTask.Duration1 = strDurationTemp1
                    tskTask.Duration2 = strDurationTemp2
                    tskTask.Duration3 = strDurationTemp3
                    End If
                End If
            End If
        End If
    Next tskTask
   
End Sub

'-------------------------------

posted on Friday, July 18, 2008 2:34 PM