Application.CalendarBarStylesEditEx method (Project)

Changes the style of the specified type of bar in the Calendar view, where Color can be a hexadecimal value.

Syntax

expression. CalendarBarStylesEditEx( _Item_, _Bar_, _Pattern_, _Color_, _Align_, _Wrap_, _Shadow_, _Field1_, _Field2_, _Field3_, _Field4_, _Field5_, _SplitPattern_ )

expression An expression that returns an Application object.

Parameters

Name Required/Optional Data type Description
Item Required Long The type of calendar bar style to edit. Can be one of the following PjBarItem constants: pjBarNonCritical, pjBarCritical, pjBarSummary, pjBarMilestone, pjBarMarked, pjBarHighlighted, pjBarProjectSummary, or pjBarExternalTask.
Bar Optional Long The bar type. Can be one of the following PjCalendarBarType constants: pjNormalBar, pjLineBar, or pjNoBar.
Pattern Optional Long The bar pattern. Can be one of the PjFillPattern constants.
Color Optional Long The bar color. 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.
Align Optional Long The justification of text in the bar. Can be one of the following PjAlignment constants: pjLeft, pjCenter, or pjRight.
Wrap Optional Boolean True if Project wraps text in the bar; otherwise, False.
Shadow Optional Boolean True if the bar has a shadow; otherwise, False.
Field1 Optional String The first field to display in the bar.
Field2 Optional String The second field to display in the bar.
Field3 Optional String The third field to display in the bar.
Field4 Optional String The fourth field to display in the bar.
Field5 Optional String The fifth field to display in the bar.
SplitPattern Optional Long The line pattern used to display split tasks. Can be one of the following PjLineType constants: pjNoLines, pjDash, pjCloseDot, pjContinuous, or pjDot.

Return value

Boolean

Remarks

Specifying a value for any of Field1 through Field5 requires that all preceding Field arguments also be specified. For example, specifying Field3 also requires Field1 and Field2 to be specified.

Note

The Field1 to Field5 parameters cannot use the PjFields constants. To see the field names that you can add to calendar bars, open the Calendar view, click the Format tab in the Calendar Tools group. Click Bar Styles on the Ribbon, and then click the Field(s) drop-down list.

Example

The following example sets critical tasks as normal bars, the color to purple with diagonal stripes, and the fields to include the task name and assigned resource names. The example also sets summary tasks as line bars and the color to green.

Sub CalendarBar_StyleEdit()
    'Activate Caldender view 
    ViewApply Name:="Calendar" 
 
    CalendarBarStylesEditEx Item:=pjBarCritical, Bar:=PjCalendarBarType.pjNormalBar, _
          Color:=&HAA00AA, Pattern:=PjFillPattern.pjDiagonalRightPattern, _
          Field1:="Name", Field2:="Resource Names" 
    CalendarBarStylesEditEx Item:=pjBarSummary, Bar:=PjCalendarBarType.pjLineBar, _
    Color:=&H1AA01 
End Sub

Note

If you use any of the PjColor enumeration constants for the Color parameter, the color will be nearly black. For example, the value of pjGreen is 9, which in the CalendarBarStylesEditEx method is a very dark red. To use only the sixteen colors available with PjColor constants, use the CalendarBarStylesEdit method.

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.