DetailForeColor Property

Microsoft Office Web Components Object Model

DetailForeColor Property

       

Returns or sets the foreground color for the specified field when the field is displayed in a detail grid. Read/write Variant.

expression.DetailForeColor

expression   Required. An expression that returns a PivotField object.

Remarks

When you set this property, you can use either a Long value representing a red-green-blue color value or a String value naming a valid HTML color value. For example, to set the object color to red, you could use the hexadecimal value &HFF, the decimal value 255, or the string value "red." In Microsoft Visual Basic, you can use the RGB function to create a red-green-blue color value (red is RGB(255,0,0)).

This property always returns the color as a Long value representing a red-green-blue color value.

Example

This example adds inserts fields into PivotTable1, add a total, and then formats the field in the detail area of the PivotTable list.

Sub Layout_PivotTable1()
    Dim vwView
    Dim ptConstants
    Dim totOrderCount
    
    Set ptConstants = PivotTable1.Constants
    Set vwView = PivotTable1.ActiveView
    
    ' Add the ShipCountry field to the row axis.
    vwView.RowAxis.InsertFieldSet vwView.FieldSets("ShipCountry")
    
    ' Add the OrderId field to the data axis.
    vwView.DataAxis.InsertFieldSet vwView.FieldSets("OrderID")
    
    ' Add the ShipVia field to the filter axis.
    vwView.FilterAxis.InsertFieldSet vwView.FieldSets("ShipVia")
    
    ' Create a total named "Order Count" that counts the OrderID field.
    Set totOrderCount = vwView.AddTotal("Order Count", vwView.FieldSets("OrderId").Fields("OrderId"), _
                        ptConstants.plFunctionCount)
    
    ' Add the Order Count total to the data axis.
    vwView.DataAxis.InsertTotal totOrderCount
    
    ' Set the horizontal alignment of the OrderID field.
    vwView.FieldSets("OrderId").Fields("OrderId").DetailHAlignment = plHAlignCenter
    
    ' Set the foreground color of the OrderId field.
    vwView.FieldSets("OrderId").Fields("OrderId").DetailForeColor = RGB(100, 100, 200)
    
End Sub