PDA

View Full Version : [SOLVED:] How can i save the highest Unique task ID in a project level custom field.



BVOPP
02-28-2022, 05:31 AM
Hallo

I want to save the highest Unique task ID in the MS Project file itself. With this i can then destinguish newly added tasks in the project.
I do not know how to do this, on task level i can but not on project level.
It looks like custom fields are only available on task and resource level but not on project level, unless you have enterprise project installed.

Hope some one knows how to arrange this in MS Project VBA

Thanks in advance.

SamT
02-28-2022, 12:39 PM
'Project level Variable
Dim HighestTask

Private Sub Project_Activate(ByVal pj As MSProject.Project)
HIghestTask = 'Code to find HT here
End Sub

BVOPP
03-01-2022, 02:39 AM
Sorry i was not clear enough in my previous quote. But i already managed, the custom fields on Project level are available. The code i created to check if task have been added:


Sub Max_UniqueID()

Dim t As Task
Dim Max_UniqueID As Long

MsgBox "This was the Max UniqueID in the project before: " & ActiveProject.Text1

For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.UniqueID > Max_UniqueID Then Max_UniqueID = t.UniqueID
End If
Next t

If Max_UniqueID <> ActiveProject.Text1 Then
MsgBox "Please check there are tasks added to the plan, previous: " & ActiveProject.Text1 & " Now: " & Max_UniqueID
ActiveProject.Text1 = Max_UniqueID
End If

End Sub