DetailHAlignment Property

Microsoft Office Web Components Visual Basic

Returns or sets the way field values are horizontally aligned when the specified field is displayed in a detail grid. By default, values are left-aligned. Read/write PivotHAlignmentEnum .

expression.DetailHAlignment

expression    Required. An expression that returns a PivotField object.

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