Application.CalendarBarStylesEdit method (Project)

Changes the style of the specified type of bar in the Calendar view.

Syntax

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

expression A variable that represents 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 one of the PjColor constants.
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.

To edit calendar bar styles where Color can be an RGB value, use the CalendarBarStylesEditEx method.

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" 
 
 CalendarBarStylesEdit Item:=pjBarCritical, Bar:=PjCalendarBarType.pjNormalBar, _ 
 Color:=PjColor.pjPurple, Pattern:=PjFillPattern.pjDiagonalRightPattern, _ 
 Field1:="Name", Field2:="Resource Names" 
 CalendarBarStylesEdit Item:=pjBarSummary, Bar:=PjCalendarBarType.pjLineBar, _ 
 Color:=PjColor.pjGreen 
End Sub

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.