Add Method

Adds an object to one of the following collections, and returns a reference to the new object:
Assignments (Syntax 1),
PayRates (Syntax 2),
SplitParts (Syntax 3),
TimeScaleValues (Syntax 4),
Projects (Syntax 5),
Resources or Tasks (Syntax 6),
ResourceGroups or TaskGroups (Syntax 7),
TaskDependencies (Syntax 8),
Availabilities (Syntax 9),
GroupCriteria (Syntax 10),
Groups (Syntax 11),
Profiles (Syntax 12),
TableFields (Syntax 13),
Tables (Syntax 14),
ViewsCombination (Syntax 15),
ViewsSingle (Syntax 16),
CodeMask (Syntax 17), or
OutlineCodes (Syntax 18).

Syntax 1

expression**.Add(TaskID, ResourceID, Units)**

*expression   * Required. An expression that returns an Assignments collection.

TaskID    Optional Long. The identification number of a task. Required if the parent object is a resource. The task is assigned the resource specified with ResourceID. The default value of TaskID is the identification number of the parent object of the Assignments collection if the parent object is a Task object.

ResourceID    Optional Long. The identification number of a resource. Required if the parent object is a task. The resource is assigned the task specified with the TaskID argument. The default value of ResourceID is the identification number of the parent object of the Assignments collection if the parent object is a Resource object.

Units    Optional Variant. The number of resource units, expressed as a decimal or percentage, to assign to the task. The default value is 1 or 100%, depending upon the Show assignment units as a setting on the Schedule tab of the Options dialog box. If the maximum number of units is less than 1 (or the maximum percentage is less than 100%), the default value of the Units argument is the maximum number of units (or the maximum percentage).

Syntax 2

expression**.Add(EffectiveDate, StdRate, OvtRate, CostPerUse)**

*expression   * Required. An expression that returns a PayRates collection.

EffectiveDate Required Variant. The date the new rate comes into effect.

StdRate    Optional Variant. The new standard rate. If not specified, the rate is the same as for the previous date period.

OvtRate    Optional Variant. The new overtime rate. If not specified, the rate is the same as for the previous date period.

CostPerUse    Optional Variant. The new cost per use. If not specified, the rate is the same as for the previous date period.

Syntax 3

expression**.Add(StartSplitPartOn, EndSplitPartOn)**

*expression   * Required. An expression that returns a SplitParts collection.

StartSplitPartOn Required Variant. The start date of the task portion.

EndSplitPartOn Required Variant. The end date of the task portion. If EndSplitPartOn is on or before the date specified with StartSplitPartOn, the portion is not created.

Remarks

If creating a new task portion would overlap any other portions in the same task, the non-coincident portions are added to the existing portion.

Syntax 4

expression**.Add(Value, Position)**

*expression   * Required. An expression that returns a TimeScaleValues collection.

Value Required Variant. The value of the timescaled data.

Position    Optional Long. The position of the new value. The default value is *n   * + 1, where n is the number of items in the collection. If the value specified for Position is n + 2 or greater, the intervening items are given a value of 0.

Syntax 5

expression**.Add(DisplayProjectInfo, Template, FileNewDialog)**

*expression   * Required. An expression that returns a Projects collection.

DisplayProjectInfo Optional Boolean. True if the Project Information dialog box appears when a new project is created. The default value is False.

Template    Optional String. A path and file name for a template to use when creating the project. If Template is omitted, a blank project is created.

FileNewDialog    Optional Boolean. True if the Templates dialog box is displayed when creating the project. If Template is specified, FileNewDialog is ignored.

Syntax 6

expression**.Add(Name, Before)**

*expression   * Required. An expression that returns a Resources or Tasks collection.

Name    Optional String. The name of the new resource or task. The default value is Empty .

Before    Optional Long. The position of the task or resource in its containing collection. The default value is the position of the last item in the collection.

Syntax 7

expression**.Add(Name, FieldName)**

*expression   * Required. An expression that returns a ResourceGroups or TaskGroups collection.

Name    Required String. The name of a group definition.

FieldName    Required String. The name of the first field to group by.

Syntax 8

expression**.Add(From, Type, Lag)**

*expression   * Required. An expression that returns a TaskDependencies collection.

From    Required Object. The Task object specified becomes a predecessor of the task specified with *expression   *.

Type    Optional Long. The type of relationship between the linked tasks. Can be one of the following PjTaskLinkType constants: pjFinishToFinish, pjFinishToStart, pjStartToFinish, or pjStartToStart. The default value is pjFinishToStart.

Lag    Optional Variant. The duration of lag time between linked tasks. To specify lead time between tasks, use a negative value. String values default to days unless otherwise specified. Non-string values are interpreted as minutes. The default value is 0.

Syntax 9

expression**.Add(AvailableFrom, AvailableTo, AvailableUnit)**

*expression   * Required. An expression that returns an Availabilities collection.

AvailableFrom    Required Variant. The earliest date the resource is available for work on the project.

AvailableTo    Required Variant. The latest date the resource is available for work on the project.

AvailableUnit    Required Double. The unit value for the availability period.

Syntax 10

expression**.Add(FieldName, Ascending, FontName, FontSize, FontBold, FontItalic, FontUnderline, FontColor, CellColor, Pattern, GroupOn, StartAt, GroupInterval)**

*expression   * Required. An expression that returns a GroupCriteria collection.

FieldName    Required String. The name of the field being grouped by.

Ascending    Optional Boolean. True if the field in a group definition should be grouped in ascending order. False if the field should be grouped in descending order. The default value is True.

FontName    Optional String. The name of the font for a group definition.

FontSize    Optional Long. The size of the font in a group definition, in points. The default value is 8.

FontBold    Optional Boolean. True if the font in a group definition is bold. The default value is True.

FontItalic    Optional Boolean. True if the font in a group definition is italic. The default value is False.

FontUnderline    Optional Boolean. True if the font in a group definition is underlined. The default value is False.

PjColor

pjColorAutomatic pjNavy
pjAqua pjOlive
pjBlack pjPurple
pjBlue pjRed
pjFuchsia pjSilver
pjGray pjTeal
pjGreen pjYellow
pjLime pjWhite
pjMaroon  

CellColor    Optional Long. The color of the cell background in a group definition. Can be one of the PjColor constants. The default value is pjColorAutomatic.

PjBackgroundPattern

pjBackgroundDarkDiagonalLeft pjBackgroundDarkDiagonalRight
pjBackgroundDarkDither pjBackgroundDarkFill
pjBackgroundDiagonalLeft pjBackgroundDiagonalRight
pjBackgroundHollow pjBackgroundLightDither
pjBackgroundLightFill pjBackgroundMediumDither
pjBackgroundMediumFill pjBackgroundMediumVerticalStripe
pjBackgroundSolidFill pjBackgroundThinVerticalStripe

PjGroupOn

pjGroupOnDateDay pjGroupOnDurationWeeks
pjGroupOnDateEachValue pjGroupOnEachValue
pjGroupOnDateHour pjGroupOnInterval
pjGroupOnDateMinute pjGroupOnOutlineEachValue
pjGroupOnDateMonth pjGroupOnOutlineLevel
pjGroupOnDateQtr pjGroupOnPct1_10
pjGroupOnDateThirdOfMonth pjGroupOnPct1_25
pjGroupOnDateWeek pjGroupOnPct1_50
pjGroupOnDateYear pjGroupOnPct1_99
pjGroupOnDurationDays pjGroupOnPctEachValue
pjGroupOnDurationEachValue pjGroupOnPctInterval
pjGroupOnDurationHours pjGroupOnTextEachValue
pjGroupOnDurationMinutes pjGroupOnTextPrefix
pjGroupOnDurationMonths  

StartAt    Optional Variant. The start of the intervals in a group definition. The default value is 0 for all fields except date fields, where it is the string "Project Start Date".

GroupInterval    Optional Variant. The interval in a group definition. The default value is 1.

Syntax 11

expression**.Add(Name, FieldName)**

*expression   * Required. An expression that returns a Groups collection.

Name    Required String. The name of the group.

FieldName    Required String. The name of the field being grouped by.

Syntax 12

expression**.Add(Name, Server, LoginType, UserName, Password)**

*expression   * Required. An expression that returns a Profiles collection.

Name    Required String. The name of the profile.

Server    Required String. A string representing the URL of the Project Server.

LoginType    Optional Long. The login type for the Project Server. Can be one of the following PjLoginType constants: pjProjectServerLogin or pjWindowsLogin. The default value is pjWindowsLogin.

UserName    Optional String. A string representing the user name.

Password    Optional String. The password for the user.

Syntax 13

expression**.Add(Field, AlignData, Width, Title, AlignTitle, Before, AutoWrap)**

*expression   * Required. An expression that returns a TableFields collection.

PjField

pjResourceAccrueAt pjTaskConfirmed
pjResourceActualCost pjTaskConstraintDate
pjResourceActualOvertimeCost pjTaskConstraintType
pjResourceActualOvertimeWork pjTaskContact
pjResourceActualOvertimeWorkProtected pjTaskCost
pjResourceActualWork pjTaskCost1-10
pjResourceActualWorkProtected pjTaskCostRateTable
pjResourceACWP pjTaskCostVariance
pjResourceAssignmentDelay pjTaskCPI
pjResourceAssignmentUnits pjTaskCreated
pjResourceAvailableFrom pjTaskCritical
pjResourceAvailableTo pjTaskCV
pjResourceBaseCalendar pjTaskCVPercent
pjResourceBaseline1-10Cost pjTaskDate1-10
pjResourceBaseline1-10Finish pjTaskDeadline
pjResourceBaseline1-10Start pjTaskDelay
pjResourceBaseline1-10Work pjTaskDemandedRequest
pjResourceBaselineCost pjTaskDuration
pjResourceBaselineFinish pjTaskDuration1-10
pjResourceBaselineStart pjTaskDuration1-10Estimated
pjResourceBaselineWork pjTaskDurationVariance
pjResourceBCWP pjTaskEAC
pjResourceBCWS pjTaskEarlyFinish
pjResourceBookingType pjTaskEarlyStart
pjResourceCanLevel pjTaskEarnedValueMethod
pjResourceCode pjTaskEffortDriven
pjResourceConfirmed pjTaskEnterpriseCost1-10
pjResourceCost pjTaskEnterpriseDate1-30
pjResourceCost1-10 pjTaskEnterpriseDuration1-10
pjResourceCostPerUse pjTaskEnterpriseFlag1-20
pjResourceCostRateTable pjTaskEnterpriseNumber1-40
pjResourceCostVariance pjTaskEnterpriseOutlineCode1-30
pjResourceCreated pjTaskEnterpriseProjectCost1-10
pjResourceCV pjTaskEnterpriseProjectDate1-30
pjResourceDate1-10 pjTaskEnterpriseProjectDuration1-10
pjResourceDemandedRequested pjTaskEnterpriseProjectFlag1-20
pjResourceDuration1-10 pjTaskEnterpriseProjectNumber1-40
pjResourceEMailAddress pjTaskEnterpriseProjectOutlineCode1-30
pjResourceEnterprise pjTaskEnterpriseProjectText1-40
pjResourceEnterpriseBaseCalendar pjTaskEnterpriseText1-40
pjResourceEnterpriseCheckedOutBy pjTaskEstimated
pjResourceEnterpriseCost1-10 pjTaskExternalTask
pjResourceEnterpriseDate1-30 pjTaskFinish
pjResourceEnterpriseDuration1-10 pjTaskFinish1-10
pjResourceEnterpriseFlag1-20 pjTaskFinishSlack
pjResourceEnterpriseGeneric pjTaskFinishVariance
pjResourceEnterpriseInactive pjTaskFixedCost
pjResourceEnterpriseIsCheckedOut pjTaskFixedCostAccrual
pjResourceEnterpriseLastModifiedDate pjTaskFixedDuration
pjResourceEnterpriseMultiValue20-29 pjTaskFlag1-20
pjResourceEnterpriseNameUsed pjTaskFreeSlack
pjResourceEnterpriseNumber1-40 pjTaskGroupBySummary
pjResourceEnterpriseOutlineCode1-29 pjTaskHideBar
pjResourceEnterpriseRBS pjTaskHyperlink
pjResourceEnterpriseRequiredValues pjTaskHyperlinkAddress
pjResourceEnterpriseTeamMember pjTaskHyperlinkHref
pjResourceEnterpriseText1-40 pjTaskHyperlinkScreenTip
pjResourceEnterpriseUniqueID pjTaskHyperlinkSubAddress
pjResourceFinish pjTaskID
pjResourceFinish1-10 pjTaskIgnoreResourceCalendar
pjResourceFlag1-20 pjTaskIndex
pjResourceGroup pjTaskIndicators
pjResourceGroupBySummary pjTaskIsAssignment
pjResourceHyperlink pjTaskLateFinish
pjResourceHyperlinkAddress pjTaskLateStart
pjResourceHyperlinkHref pjTaskLevelAssignments
pjResourceHyperlinkScreenTip pjTaskLevelCanSplit
pjResourceHyperlinkSubAddress pjTaskLevelDelay
pjResourceID pjTaskLinkedFields
pjResourceIndex pjTaskMarked
pjResourceIndicators pjTaskMilestone
pjResourceInitials pjTaskName
pjResourceIsAssignment pjTaskNotes
pjResourceLevelingDelay pjTaskNumber1-20
pjResourceLinkedFields pjTaskObjects
pjResourceMaterialLabel pjTaskOutlineCode1-10
pjResourceMaxUnits pjTaskOutlineLevel
pjResourceName pjTaskOutlineNumber
pjResourceNotes pjTaskOverallocated
pjResourceNumber1-20 pjTaskOvertimeCost
pjResourceObjects pjTaskOvertimeWork
pjResourceOutlineCode1-10 pjTaskParentTask
pjResourceOverallocated pjTaskPercentComplete
pjResourceOvertimeCost pjTaskPercentWorkComplete
pjResourceOvertimeRate pjTaskPhysicalPercentComplete
pjResourceOvertimeWork pjTaskPredecessors
pjResourcePeakUnits pjTaskPreleveledFinish
pjResourcePercentWorkComplete pjTaskPreleveledStart
pjResourcePhonetics pjTaskPriority
pjResourceProject pjTaskProject
pjResourceRegularWork pjTaskRecurring
pjResourceRemainingCost pjTaskRegularWork
pjResourceRemainingOvertimeCost pjTaskRemainingCost
pjResourceRemainingOvertimeWork pjTaskRemainingDuration
pjResourceRemainingWork pjTaskRemainingOvertimeCost
pjResourceResponsePending pjTaskRemainingOvertimeWork
pjResourceSheetNotes pjTaskRemainingWork
pjResourceStandardRate pjTaskResourceEnterpriseMultiValueCode20-29
pjResourceStart pjTaskResourceEnterpriseOutlineCode1-29
pjResourceStart1-10 pjTaskResourceEnterpriseRBS
pjResourceSV pjTaskResourceGroup
pjResourceTaskSummaryName pjTaskResourceInitials
pjResourceTeamStatusPending pjTaskResourceNames
pjResourceText1-30 pjTaskResourcePhonetics
pjResourceType pjTaskResourceType
pjResourceUniqueID pjTaskResponsePending
pjResourceUpdateNeeded pjTaskResume
pjResourceVAC pjTaskResumeNoEarlierThan
pjResourceWindowsUserAccount pjTaskRollup
pjResourceWork pjTaskSheetNotes
pjResourceWorkContour pjTaskSPI
pjResourceWorkgroup pjTaskStart
pjResourceWorkVariance pjTaskStart1-10
pjTaskActualCost pjTaskStartSlack
pjTaskActualDuration pjTaskStartVariance
pjTaskActualFinish pjTaskStatus
pjTaskActualOvertimeCost pjTaskStatusIndicator
pjTaskActualOvertimeWork pjTaskStop
pjTaskActualOvertimeWorkProtected pjTaskSubproject
pjTaskActualStart pjTaskSubprojectReadOnly
pjTaskActualWork pjTaskSuccessors
pjTaskActualWorkProtected pjTaskSummary
pjTaskACWP pjTaskSV
pjTaskAssignmentDelay pjTaskSVPercent
pjTaskAssignmentUnits pjTaskTCPI
pjTaskBaseline1-10Cost pjTaskTeamStatusPending
pjTaskBaseline1-10Duration pjTaskText1-30
pjTaskBaseline1-10DurationEstimated pjTaskTotalSlack
pjTaskBaseline1-10Finish pjTaskType
pjTaskBaseline1-10Start pjTaskUniqueID
pjTaskBaseline1-10Work pjTaskUniquePredecessors
pjTaskBaselineCost pjTaskUniqueSuccessors
pjTaskBaselineDuration pjTaskUpdateNeeded
pjTaskBaselineDurationEstimated pjTaskVAC
pjTaskBaselineFinish pjTaskWBS
pjTaskBaselineStart pjTaskWBSPredecessors
pjTaskBaselineWork pjTaskWBSSuccessors
pjTaskBCWP pjTaskWork
pjTaskBCWS pjTaskWorkContour
pjTaskCalendar pjTaskWorkVariance

AlignData    Optional Long. The alignment of the table data. Can be one of the following PjAlignment constants: pjCenter, pjLeft, or pjRight. The default value is pjRight.

Width    Optional Long. The width of the table field in points. The default value is 10.

Title    Optional String. The title of the table field.

AlignTitle    Optional Long. The alignment of the title. Can be one of the PjAlignment constants. The default value is pjCenter.

Before    Optional Long. Position of the title. The default value is -1.

AutoWrap    Optional Boolean. True if the data in the table field automatically wrap. The default value is True.

Syntax 14

expression**.Add(Name, Field, Task)**

*expression   * Required. An expression that returns a Tables collection.

Name    Required String. The name of the table.

Field    Required Long. The name of the field. Can be one of the PjField constants.

Task    Optional Boolean. True if the table being added is a task table. The default value is True.

Syntax 15

expression**.Add(Name, TopView, BottomView, ShowInMenu)**

*expression   * Required. An expression that returns a ViewsCombination collection.

Name    Required String. The name of the combination view.

TopView    Required String. The view that appears in the top pane of a combination view.

BottomView    Required String. The view that appears in the bottom pane of a combination view.

ShowInMenu    Optional Boolean. True if Project Server shows the view in the View menu. The default value is False.

Syntax 16

expression**.Add(Name, Screen, ShowInMenu, Table, Filter, Group, HighlightFilt)**

*expression   * Required. An expression that returns a ViewsSingle collection.

Name    Required String. The name of the view.

PjViewScreen

pjCalendar pjResourceSheet
pjGantt pjResourceUsage
pjNetworkDiagram pjTaskDetailsForm
pjRelationshipDiagram pjTaskForm
pjResourceForm pjTaskNameForm
pjResourceGraph pjTaskSheet
pjResourceNameForm pjTaskUsage

ShowInMenu    Optional Boolean. True if Project Server adds the single-pane view to the View menu. The default value is False.

Table    Optional Variant. Specifies the table to be used by the view. This value is ignored if the view specified with the Screen argument does not use tables.

Filter    Optional Variant. Specifies the filter to be used on the view.

Group    Optional Variant. Specifies the group to be used by the view. If a group is required for the view, but none is specified, the default is No Group. This value is ignored if the view specified with the Screen argument does not use groups.

HighlightFilt    Optional Boolean. True if the filter applied is a highlight filter. The default value is False.

Syntax 17

expression**.Add(Sequence, Length, Separator)**

*expression   * Required. An expression that returns a CodeMask collection. Note: The CodeMask.Add() method returns a CodeMaskLevel object.

PjCustomOutlineCodeSequence

pjCustomOutlineCodeCharacters pjCustomOutlineCodeLowercaseLetters
pjCustomOutlineCodeNumbers pjCustomOutlineCodeUppercaseLetters

Length    Optional Variant. Specifies the length for a given level in the code mask. Can be the string "Any" or an integer value between 1 and 255.

Separator    Optional String. The character that separates the level of a code mask from the next code mask. Can be one of the following characters: ".", "-", "+", or "/".

Syntax 18

expression**.Add(FieldID, Name)**

*expression   * Required. An expression that returns an OutlineCodes collection.

PjCustomField

pjCustomProjectEnterpriseCost1 - 10 pjCustomProjectEnterpriseDate1 - 30
pjCustomProjectEnterpriseDuration1 - 10 pjCustomProjectEnterpriseFlag1 - 20
pjCustomProjectEnterpriseNumber1 - 40 pjCustomProjectEnterpriseOutlineCode1 - 30
pjCustomProjectEnterpriseText1 - 40 pjCustomResourceCost1 - 10
pjCustomResourceDate1 - 10 pjCustomResourceDuration1 - 10
pjCustomResourceEnterpriseCost1 - 10 pjCustomResourceEnterpriseDate1 - 30
pjCustomResourceEnterpriseDuration1 - 10 pjCustomResourceEnterpriseFlag1 - 20
pjCustomResourceEnterpriseNumber1 - 40 pjCustomResourceEnterpriseOutlineCode1 - 30
pjCustomResourceEnterpriseRBS/ pjCustomResourceEnterprise1 - 10
pjCustomResourceEnterpriseText1 - 40 pjCustomResourceFinish1 - 10
pjCustomResourceFlag1 - 20 pjCustomResourceNumber1 - 20
pjCustomResourceOutlineCode1 - 10 pjCustomResourceStart1 - 10
pjCustomResourceText1 - 30 pjCustomTaskCost1 - 10
pjCustomTaskDate1 - 10 pjCustomTaskDuration1 - 10
pjCustomTaskEnterpriseCost1 - 10 pjCustomTaskEnterpriseDate1 - 30
pjCustomTaskEnterpriseDuration1 - 10 pjCustomTaskEnterpriseFlag1 - 20
pjCustomTaskEnterpriseNumber1 - 40 pjCustomTaskEnterpriseOutlineCode1 - 20
pjCustomTaskEnterpriseText1 - 40 pjCustomTaskEnterpriseFlag1 - 20
pjCustomTaskNumber1 - 20 pjCustomTaskOutlineCode1 - 10
pjCustomTaskStart1 - 10 pjCustomTaskText1 - 30

Name    Required String. The name of the OutlineCode to add.

Remarks

In Microsoft Office Project Professional   2003, you can also add a table (Syntax 14) or a view (Syntax 15 and 16) to the enterprise global template. First open the enterprise global template, making it the active project, and then run the Add method.

Example

The following example adds a new task at the end of the list.

Sub AddTask()
    ActiveProject.Tasks.Add Name:="New Task"
End Sub

The following example adds a resource identified by the number of 212 as a new assignment for the specified task.

Sub AddResource()
    ActiveProject.Tasks(1).Assignments.Add ResourceID:=212
End Sub

Applies to | Assignment Object, Assignments Collection Object | Availability Object, Availabilities Collection Object | CodeMask Collection Object | Group Object, Groups Collection Object | GroupCriterion Object, GroupCriteria Collection Object | OutlineCode Object, OutlineCodes Collection Object | PayRate Object, PayRates Collection Object | Profile Object, Profiles Collection Object | Project Object, Projects Collection Object | Resource Object, Resources Collection Object | SplitPart Object, SplitParts Collection Object | Table Object, Tables Collection Object | TableField Object, TableFields Collection Object | Task Object, Tasks Collection Object | TaskDependency Object, TaskDependencies Collection Object | TimeScaleValue Object, TimeScaleValues Collection Object | ViewCombination Object, ViewsCombination Collection Object | ViewSingle Object, ViewsSingle Collection Object

See Also | Count Property | Delete Method | Index Property | ResourceAssignment Method