如何更改MS Project上的数据

时间:2015-10-29 23:33:28

标签: vba ms-project

有没有办法可以使用vb.net更改项目的持续时间?我试图录制一个宏但是一旦我运行它就没有做我在录制期间所做的事情。它正在选择不同的行/列。而且我注意到该行有负值,我在这里包括宏。

Sub Macro3()
    SelectTaskField Row:=-3, Column:="Actual Start"
    SelectTaskField Row:=4, Column:="Actual Duration"
    SelectTaskField Row:=5, Column:="Actual Duration"
    SelectTaskField Row:=-3, Column:="Start"
    SelectTaskField Row:=-2, Column:="Finish"
    SelectTaskField Row:=1, Column:="Name"
    SelectTaskField Row:=-3, Column:="Actual Start"
    SelectTaskField Row:=-4, Column:="Actual Start"
    SelectTaskField Row:=4, Column:="Actual Start", Height:=1
    SelectTaskField Row:=5, Column:="Actual Start", Height:=1
    SelectTaskField Row:=3, Column:="Actual Start"
    SelectTaskField Row:=-3, Column:="Duration"
    SelectTaskField Row:=-4, Column:="Actual Start"
    SelectTaskField Row:=-3, Column:="Duration"
End Sub

谢谢!

1 个答案:

答案 0 :(得分:0)

我已经设法使用宏来改变持续时间,但有没有办法可以更快地完成它?我阅读了每个任务,但有没有一种方法可以更快地将所有持续时间乘以2?

Public Sub toggleMissingBaseline()
  On Error GoTo ErrorHandler

  Dim tsks As Tasks
  Dim t As Task
  Dim rgbColor As Long

  Set tsks = ActiveProject.Tasks
    OutlineShowSubTasks
  For Each t In tsks
    OutlineShowSubTasks
    SelectTaskField Row:=t.ID, Column:="Duration", RowRelative:=False
    If (Not t Is Nothing) And (Not t.Summary) Then
         t.Duration = t.Duration * 2
    End If
  Next t
End Sub