Application.BoxFormat method (Project)
Formats individual boxes in the Network Diagram view (PERT chart).
Syntax
expression. BoxFormat
( _ProjectName_
, _TaskID_
, _DataTemplate_
, _HorizontalGridlines_
, _VerticalGridlines_
, _BorderShape_
, _BorderColor_
, _BorderWidth_
, _BackgroundColor_
, _BackgroundPattern_
, _Reset_
)
expression A variable that represents an Application object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
ProjectName | Optional | String | The name of the project containing TaskID when working with consolidated projects. The default value is the name of the active project. |
TaskID | Optional | Long | The 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. |
DataTemplate | Optional | String | The name of the data template to use. |
HorizontalGridlines | Optional | Boolean | True if horizontal gridlines separate each row in the box; otherwise, False. |
VerticalGridlines | Optional | Boolean | True if vertical gridlines separate each column in the box; otherwise, False. |
BorderShape | Optional | Long | The shape of the box border. Can be one of the PjBoxShape constants. |
BorderColor | Optional | Long | The color of the box border. Can be one of the PjColor constants. |
BorderWidth | Optional | Long | Specifies the box border width, where values can be 1 to 4 for the four line widths shown in the Format Box dialog box. |
BackgroundColor | Optional | Long | The color of the box background. Can be one of the PjColor constants. |
BackgroundPattern | Optional | Long | The pattern for the background. Can be one of the PjBackgroundPattern constants. |
Reset | Optional | Boolean | True 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
Boolean
Remarks
If TaskID is specified, the associated task cannot be hidden due to application of a filter or a collapsed outline structure.
Using the BoxFormat method without specifying any arguments displays the Format Box dialog box for the selected tasks. If no tasks are selected, the BoxFormat method has no effect.
Use the BoxFormat method to change the formatting of boxes from their default styles. To define the default styles, use the BoxStylesEdit or BoxStylesEditEx method.
To format Network Diagram boxes using hexadecimal values for BorderColor and BackgroundColor, see the BoxFormatEx method.
Example
The following example changes the 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"
BoxFormat TaskID:="2", bordershape:=pjBoxRoundedRectangle, VerticalGridlines:=True, _
BorderWidth:=2, backgroundpattern:=pjBackgroundLightDither, _
Backgroundcolor:=pjBlue, BorderColor:=pjRed
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.