Application.BoxSet method (Project)

Creates, selects, or moves a task in the Network Diagram view.

Syntax

expression.BoxSet (action, TaskID, XPosition, YPosition, ProjectName)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
action Optional Long The operation to perform on the specified task(s). The default value is pjBoxSelect. Can be one of the PjBoxSet constants.
TaskID Optional Long The identification number of the task. If action is pjBoxCreate, TaskID is ignored.
XPosition Optional Long The horizontal position of the task, in pixels. Required if action is pjBoxMoveAbsolute or pjBoxMoveRelative.

If action is pjBoxCreate or pjBoxMoveAbsolute, XPosition is the absolute horizontal position of the upper-left corner of the task.

If action is pjBoxMoveRelative, XPosition is the amount to move the task horizontally relative to the current position.

If action is pjBoxAddToSelection, pjBoxSelect, or pjBoxUnselect, XPosition is ignored.
YPosition Optional Long The vertical position of the task, in pixels. Required if action is pjBoxMoveAbsolute or pjBoxMoveRelative.

If action is pjBoxCreate or pjBoxMoveAbsolute, YPosition is the absolute vertical position of the upper-left corner of the task.

If action is pjBoxMoveRelative, YPosition is the amount to move the task vertically relative to the current position.

If action is pjBoxAddToSelection, pjBoxSelect, or pjBoxUnselect, YPosition is ignored.
ProjectName Optional String If the active project is a consolidated project, specifies the name of the project for the identification number specified by TaskID. If TaskID is not specified, ProjectName is ignored. The default value is the name of the active project.

Return value

Boolean

Remarks

If only one task box is selected, specifying pjBoxUnselect has no effect.

If automatic layout has been activated for the Network Diagram view, XPosition and YPosition have no effect.

Example

The following example adds the task with TaskID 2 to the selected tasks.

Sub Box_Set() 
 
 'Activate the Network Diagram view 
 ViewApply Name:="Network Diagram" 
 BoxSet action:=pjBoxAddToSelection, TaskID:="2" 
End Sub

Note

BoxSet does not currently work for subprojects. You can place the subproject name in the Project Name attribute and set the TaskID, but it does not perform the action to the box from the subproject in the Network Diagram.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.