2
votes

I am a VB developer working with MPP files for the first time.

My code reads data from Excel and writes to the mpp file successfully for some set of columns and rows.

1) How to select the single cell in the MPP file, because I have a scenario where I compare with next row cell and do some operation

2) Why can't we have customized columns in mpp file (Like Computer name, Disc name etc) its giving an error

3) How to indent the cells keep one cell as master others underneath it and it should traverse through loop

code to delete the all tasks

For Each oSubTasks In oTasks
    If Not oSubTasks Is Nothing Then
        oSubTasks.Delete
    End If
Next oSubTasks

code to get the column value

For Each oSubTasks In oTasks
'if the frist row is blank
    If oSubTasks.GetField(FieldNameToFieldConstant("Duration")) = "" Then Exit For
    If oSubTasks.GetField(FieldNameToFieldConstant("Duration")) <> "" Then
         Mpplastrow = Mpplastrow + 1
    End If
Next oSubTasks

code for customized column getting error

If oSubTasks.GetField(FieldNameToFieldConstant("computer name")) = sh1.Cells(rw, primecol).Value Then
'    oTask.SetField FieldID:=oApp.FieldNameToFieldConstant("computer name"), Value:=sh1.Cells(rw, primecol).Value
'Else
'    oTask.SetField FieldID:=oApp.FieldNameToFieldConstant("computer name"), Value:=sh1.Cells(rw, primecol).Value
'End If
1
have you read my answer and code below ? did you mean something like that ?Shai Rado

1 Answers

0
votes

To read the Indent level of each MSP tasks, and to be able to Indent inside (or outside), try something like the code below:

Option Explicit

Sub IndentTasks()

Dim Tsk As Task

For Each Tsk In ThisProject.Tasks            
    Select Case Tsk.OutlineLevel '<-- read the current taks Outline Level
        Case 1
            If Tsk.ID <> 1 Then
                Tsk.OutlineIndent '<-- indent inside (to the right)
            End If

        Case Is > 6 '<-- don;t want your Project to be too indented inside
            Tsk.OutlineOutdent '<-- indent outside (to the left)

    End Select
Next Tsk

End Sub