Consulting

Results 1 to 3 of 3

Thread: How can i save the highest Unique task ID in a project level custom field.

  1. #1
    VBAX Newbie
    Joined
    Feb 2022
    Posts
    5
    Location

    How can i save the highest Unique task ID in a project level custom field.

    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.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    'Project level Variable
    Dim HighestTask
    
    Private Sub Project_Activate(ByVal pj As MSProject.Project) 
        HIghestTask = 'Code to find HT here
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Newbie
    Joined
    Feb 2022
    Posts
    5
    Location
    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
    Last edited by Bob Phillips; 03-01-2022 at 03:21 AM. Reason: Added code tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •