我只是想为每个任务和资源添加每天的实际工作时间数据?
我如何在实际工作列上写一个小时(例如,X task R Resource在07.02.21上工作4小时,在07.03.21上工作3小时我如何使用vba宏将这些数据添加到MS Project中(
示例:
Dim tsk as Task
Dim finder as string
dim names as string
for each tsk in activeproject.tasks
if instr(tsk.text1, "TASK CODE" )> 0 then
finder= tsk.text1
if instr(tsk.ResourceNames, "Name")>0 then
' Implement the actual data codes here
endif
endif
next tsk
总结
如何将实际工作的数据添加到特定任务中的特定人员。
所需的方法是TimeScaleData。下面是一个如何使用它在资源分配级别设置7/2和7/3的实际工作时间的示例:
Sub SetActualHours()
Dim tsk As Task
Dim names As String
For Each tsk In ActiveProject.Tasks
If InStr(tsk.Text1, "TASK CODE") > 0 Then
Dim asn As Assignment
For Each asn In tsk.Assignments
If asn.Resource.Name = "Name" Then
Dim tsv As TimeScaleValues
Set tsv = asn.TimeScaleData(StartDate:=#7/2/2021#, EndDate:=#7/4/2021# _
, Type:=pjAssignmentTimescaledActualWork, TimeScaleUnit:=pjTimescaleDays)
tsv(1).Value = 4 * 60
tsv(2).Value = 3 * 60
End If
Next asn
End If
Next tsk
End Sub