Table of contents
Collapse the table of content
Expand the table of content

Application.BoxFormatEx Method (Project)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Formats individual boxes in the Network Diagram view (PERT chart), where colors can be specified with hexadecimal values.


expression. BoxFormatEx( ** ProjectName, ** TaskID, ** DataTemplate, ** HorizontalGridlines, ** VerticalGridlines, ** BorderShape, ** BorderColor, ** BorderWidth, ** BackgroundColor, ** BackgroundPattern, ** Reset** )

expression An expression that returns an Application object.


NameRequired/OptionalData TypeDescription
ProjectNameOptionalStringThe name of the project containing TaskID when working with consolidated projects. The default value is the name of the active project.
TaskIDOptionalLongThe identification number of the task represented by the box to change. The default behavior is to change the boxes that represent one or more selected tasks.
DataTemplateOptionalStringThe name of the data template to use.
HorizontalGridlinesOptionalBooleanTrue if horizontal gridlines separate each row in the box; otherwise, False.
VerticalGridlinesOptionalBooleanTrue if vertical gridlines separate each column in the box; otherwise, False.
BorderShapeOptionalLongThe shape of the box border. Can be one of the PjBoxShape constants.
BorderColorOptionalLongThe color of the box border. Can be a hexadecimal value for the RGB color, where red is the last byte. For example, the value &;HFF0000 is blue and &;H00FFFF is yellow.
BorderWidthOptionalLongSpecifies the box border width, where values can be 1 to 4 for the four line widths shown in the Format Box dialog box.
BackgroundColorOptionalLongThe color of the box background. Can be a hexadecimal value, where red is the last byte. For example, the value &;HFFFF00 is blue-green and &;HFF00FF is purple.
BackgroundPatternOptionalLongThe pattern for the background. Can be one of the PjBackgroundPattern constants.
ResetOptionalBooleanTrue if the box formatting is reset to the default style as shown in the Box Styles dialog box. If Reset is True, all arguments except ProjectName and TaskID are ignored.

Return Value



If TaskID is specified, the associated task cannot be hidden due to application of a filter or a collapsed outline structure.

Using the BoxFormatEx method with no arguments displays the Format Box dialog box for the selected tasks. If no tasks are selected, the BoxFormatEx method has no effect.

Use the BoxFormatEx method to change the formatting of boxes from their default styles. To define the default styles, use the BoxStylesEdit or the BoxStylesEditEx method.


The following example changes the box border color to red and the background color to a light blue dithered pattern.

Sub BoxFormat_Color() 
    'Activate the Network Diagram view
    ViewApply Name:="Network Diagram"

    BoxFormatEx TaskID:="2", bordershape:=pjBoxRoundedRectangle, VerticalGridlines:=False, _
        BorderWidth:=3, backgroundpattern:=pjBackgroundLightDither, _
        BackgroundColor:=&;HFF0000, BorderColor:=&;HFF
End Sub

Note If you use any of the PjColor constants for the BorderColor or BackgroundColor parameters, the color will be nearly black. For example, the value of pjGreen is 9, which in the BoxFormatEx method is a very dark red. To use only the sixteen colors available with PjColor constants, use theBoxFormat method.

© 2018 Microsoft