Application.GanttBarFormat method (Project)

Changes the formatting of Gantt bars from their default styles.

Syntax

expression. GanttBarFormat( _TaskID_, _GanttStyle_, _StartShape_, _StartType_, _StartColor_, _MiddleShape_, _MiddlePattern_, _MiddleColor_, _EndShape_, _EndType_, _EndColor_, _LeftText_, _RightText_, _TopText_, _BottomText_, _InsideText_, _Reset_, _ProjectName_ )

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
TaskID Optional Long The identification number of the task to be changed on the Gantt chart. The default is to change the Gantt bars of the selected tasks.
GanttStyle Optional Integer The style applied to the Gantt bar to be formatted. The value for GanttStyle is based on the position of the bar style in the Bar Styles dialog box. For example, the value 3 returns the third bar style in the list.
StartShape Optional Long The start shape of the Gantt bar. Can be one of the PjBarEndShape constants.
StartType Optional Long The start type of the Gantt bar. Can be one of the PjBarType constants.
StartColor Optional Long The color of the start shape of the Gantt bar. Can be one of the PjColor constants.
MiddleShape Optional Long The middle shape of the Gantt bar. Can be one of the PjBarShape constants.
MiddlePattern Optional Long The middle pattern of the Gantt bar. Can be one of the PjFillPattern constants.
MiddleColor Optional Long The color of the middle section Gantt bar. Can be one of the PjColor constants.
EndShape Optional Long The end shape of the Gantt bar. Can be one of the PjBarEndShape constants.
EndType Optional Long The end type of the Gantt bar. Can be one of the following PjBarType constants: pjDashed, pjFramed, or pjSolid.
EndColor Optional Long The color of the end shape of the Gantt bar. Can be one of the PjColor constants.
LeftText Optional String The task field to display to the left of the Gantt bar.
RightText Optional String The task field to display to the right of the Gantt bar.
TopText Optional String The task field to display above the Gantt bar.
BottomText Optional String The task field to display below the Gantt bar.
InsideText Optional String The task field to display inside the Gantt bar.
Reset Optional Boolean True if the bar formatting is reset to the default formatting of the style in the Bar Styles dialog box; otherwise, False.
ProjectName Optional String The name of the project containing TaskID if consolidation is involved. The default value is the name of the active project.

Return value

Boolean

Remarks

Using the GanttBarFormat method without specifying any arguments displays the Format Bar dialog box.

To define the default styles, use the GanttBarStyleEdit method.

To change Gantt bar formatting where colors can be hexadecimal RGB values, use the GanttBarFormatEx method.

Example

The following example displays a red diamond shape for the start of the task with the Task ID of 3.

Sub GanttBar_Format() 
 
 'Activate Gantt Chart view 
 ViewApply Name:="&Gantt Chart" 
 GanttBarFormat TaskID:=3, StartShape:=pjDiamond, StartType:=pjSolid, StartColor:=pjRed 
 
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.