次の方法で共有


Code to Show Which Tasks have Which Baselines Saved

Here is a sample of some VBA code that will populate the Task Text30 field with the numbers of the baselines for which each task has values saved. This is useful if you are using lots of the baselines but not all your tasks have had all the baselines saved.

For example:

image

“Task” has values in Baseline, Baseline2, Baseline4 and Baseline9 while “Other Task” only has values in Baseline2.

 

    1:  Sub WhichBaselinesSaved()
    2:  Dim t As Task
    3:  Dim i As Long
    4:   
    5:  For Each t In ActiveProject.Tasks
    6:      If Not (t Is Nothing) Then
    7:          t.Text30 = ""
    8:          For i = 0 To 10
    9:              If i = 0 Then
   10:                  If t.BaselineStart < 50000 Then
   11:                      t.Text30 = t.Text30 & i & ", "
   12:                  End If
   13:              ElseIf Not t.GetField(Application.FieldNameToFieldConstant("Baseline" _
   14:              & i & "Start", pjTask)) = "NA" Then
   15:                      t.Text30 = t.Text30 & i & ", "
   16:              End If
   17:          Next i
   18:          t.Text30 = Left$(t.Text30, Len(t.Text30) - 2)
   19:      End If
   20:      
   21:  Next t
   22:  End Sub

Comments

  • Anonymous
    September 24, 2009
    Thank you for your macro. I mentioned your blog and this macro tip on my website September 25, 2009. Don donwlarson@gmail.com