我希望能够在MS项目文件中找到特定的UID。我发现下面的代码,但它不工作…我在网上找到了它的宏。
Sub FindUID()
Dim T As Task
Dim Temp_UID As Integer
Dim UID As Integer
Dim ID As Integer
ActiveProject.ProjectSummaryTask.Number10 = Application.ActiveSelection.Tasks.Item(1).UniqueID
UID = InputBox("Enter UID", "UID")
ID = 1
ActiveProject.AutoFilter = True
For Each T In ActiveProject.Tasks
Temp_UID = T.UniqueID
If Temp_UID = UID Then
ID = T.ID
End If
Debug.Print T.UniqueID
Next T
If ID <> 1 Then
SelectRow Row:=ID, RowRelative:=False
Else
MsgBox "UID Not Found", vbOKOnly, "Error"
End If
ActiveProject.AutoFilter = True
OutlineShowAllTasks
End Sub
要跳转到任务,请使用Find方法。Find可用于任何字段和各种测试(例如equals、contains等)。例如:
Sub GotoUID()
' make sure all tasks are shown
SummaryTasksShow True
FilterApply "All Tasks"
SelectAll
OutlineShowAllTasks
SelectBeginning
Dim UID As Integer
UID = InputBox("Enter UID", "UID")
Find "Unique ID", "equals", UID
End Sub