OutlineCode Object (Project)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Represents a local outline code in Project. The OutlineCode object is a member of the OutlineCodes collection.

Using the OutlineCode Object

The following example adds a custom outline code to store the location of resources and configures the outline code so that only values specified in the lookup table can be associated with a resource.

Sub CreateLocationOutlineCode() 
    Dim objOutlineCode As OutlineCode 
    Set objOutlineCode = ActiveProject.OutlineCodes.Add( _
        pjCustomResourceOutlineCode1, "Location") 
    objOutlineCode.OnlyLookUpTableCodes = True 
    DefineLocationCodeMask objOutlineCode.CodeMask 
    EditLocationLookupTable objOutlineCode.LookupTable 
End Sub 
Sub DefineLocationCodeMask(objCodeMask As CodeMask) 
    objCodeMask.Add _
        Sequence:=pjCustomOutlineCodeUppercaseLetters, _
        Length:=2, Separator:="." 
    objCodeMask.Add _ 
        Sequence:=pjCustomOutlineCodeUppercaseLetters, _
    objCodeMask.Add _
        Sequence:=pjCustomOutlineCodeUppercaseLetters, _
        Length:=3, Separator:="." 
End Sub 
Sub EditLocationLookupTable(objLookupTable As LookupTable) 
    Dim objStateEntry As LookupTableEntry 
    Dim objCountyEntry As LookupTableEntry 
    Dim objCityEntry As LookupTableEntry 
    Set objStateEntry = objLookupTable.AddChild("WA") 
    objStateEntry.Description = "Washington" 
    Set objCountyEntry = objLookupTable.AddChild("KING", _
    objCountyEntry.Description = "King County" 
    Set objCityEntry = objLookupTable.AddChild("SEA", _
    objCityEntry.Description = "Seattle" 
    Set objCityEntry = objLookupTable.AddChild("RED", _
    objCityEntry.Description = "Redmond" 
    Set objCityEntry = objLookupTable.AddChild("KIR", _
    objCityEntry.Description = "Kirkland" 
End Sub

An outline code is a type of local custom field that has a hierarchical text lookup table. Enterprise custom fields of type Text that have hierarchical lookup tables act as outline codes. Use the OutlineCodes property to return an OutlineCodes collection. Use the Add method to add a local outline code to the OutlineCodes collection. To add an enterprise custom field, you must use Project Web App or the Project Server Interface (PSI).