【问题标题】:MS Project 2016 VBA Assignment UniqueID not matching screenMS Project 2016 VBA 分配 UniqueID 不匹配屏幕
【发布时间】:2017-02-18 17:34:13
【问题描述】:

我有一个简单的任务,只有一个任务。在 Task Usage 视图中,我显示了 UniqueID 列,它给出了 Assignment Unique ID 为 1048577。

然后我运行以下示例代码来检查该分配 ID:

Sub CheckAssignments()
    Dim oldTsks As Tasks
    Dim wrdAss As Assignment
    Dim wrdAss2 As Assignment

    Set prj = ActiveProject


    Set oldTsks = ActiveSelection.Tasks

    For Each t In oldTsks
        Debug.Print "Task ID: " & t.ID & " Task UID: " & t.UniqueID & " Task Name: " & t.Name & " Assignment Count: " & t.Assignments.Count
        For Each a In t.Assignments
            Debug.Print "   Assignment UID is: " & a.UniqueID
            Debug.Print "   Assignment Resource is: " & a.ResourceUniqueID & " - " & a.ResourceName
            Debug.Print "   Assignment Index is: " & a.Index
        Next
    Next

End Sub

当我运行这个(确保选择正确的任务)时,我得到以下结果集:

Task ID: 1 Task UID: 1 Task Name: New Task Assignment Count: 1
   Assignment UID is: 2097153
   Assignment Resource is: 1 - Fred
   Assignment Index is: 1

问题:2097153 是从哪里来的????为什么我在遍历 Assignments 集合时找不到 1048577?

【问题讨论】:

    标签: vba ms-project


    【解决方案1】:

    看起来这是 MS Project 中的一个已知错误。显然,在遍历 assignments 对象时,ID 偏离了 2^20 或 1,048,576。您可以使用任一编号引用分配,但真正的问题是,Assignments 集合在按对象迭代时不稳定。我最终使用的解决方法是使用 Assignments.Count 属性并从 1 迭代到 Count,而不是在 Assignments 中使用 For Each a。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-15
      • 2016-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-16
      相关资源
      最近更新 更多