Add reference to:
- Microsoft Office Project 16 Object Library.
Imports Microsoft.Office.Interop
Module Module1
Sub Main()
Dim ProjApp As New MSProject.Application
ProjApp.ScreenUpdating = False
ProjApp.Visible = True
ProjApp.FileNew()
Dim proj As MSProject.Project = ProjApp.ActiveProject
'Creating a task
Dim tas1Name As MSProject.Task = proj.Tasks.Add("Task1")
'Assigning the task some resources
tas1Name.ResourceNames = "res1,res2,res3"
Dim tas2Name As MSProject.Task = proj.Tasks.Add("Task2")
tas2Name.ResourceNames = "res1"
Dim tas3Name As MSProject.Task = proj.Tasks.Add("Task3")
tas3Name.ResourceNames = "res1"
Dim tas4Name As MSProject.Task = proj.Tasks.Add("Task4")
tas4Name.ResourceNames = "res1"
Dim tas5Name As MSProject.Task = proj.Tasks.Add("Task5")
tas5Name.ResourceNames = "res2"
Dim tas6Name As MSProject.Task = proj.Tasks.Add("Task6")
tas6Name.ResourceNames = "res2"
'Specify predecessors
tas2Name.LinkPredecessors(tas1Name)
tas3Name.LinkPredecessors(tas1Name)
tas4Name.LinkPredecessors(tas1Name)
tas4Name.LinkPredecessors(tas2Name)
tas4Name.LinkPredecessors(tas3Name)
tas6Name.LinkPredecessors(tas5Name)
tas4Name.LinkPredecessors(tas6Name)
'ProjApp.LevelingOptions(True)
'ProjApp.LevelNow()
tas1Name.SetField(MSProject.PjField.pjTaskManual, Value:="No")
tas2Name.SetField(MSProject.PjField.pjTaskManual, Value:="No")
tas3Name.SetField(MSProject.PjField.pjTaskManual, Value:="No")
tas4Name.SetField(MSProject.PjField.pjTaskManual, Value:="No")
tas5Name.SetField(MSProject.PjField.pjTaskManual, Value:="No")
tas6Name.SetField(MSProject.PjField.pjTaskManual, Value:="No")
MsgBox("about to change the durations")
End Sub
End Module
No comments:
Post a Comment