Share via


Workbook.Styles Property (2007 System)

Gets a Styles collection that represents all the styles in the workbook.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Styles As Styles
'Usage
Dim instance As Workbook 
Dim value As Styles 

value = instance.Styles
[BrowsableAttribute(false)]
public Styles Styles { get; }
[BrowsableAttribute(false)]
public:
property Styles^ Styles {
    Styles^ get ();
}
public function get Styles () : Styles

Property Value

Type: Styles
A Styles collection that represents all the styles in the workbook.

Examples

The following code example uses the Styles property to adjust some of the properties of each Style in the workbook, including text wrapping, vertical and horizontal alignment, and hiding formulas.

This example is for a document-level customization.

Private Sub SetWorkbookStyles()
    Dim i As Integer 
    For i = 1 To Me.Styles.Count
        Me.Styles(i).WrapText = True 
        Me.Styles(i).VerticalAlignment = Excel.XlVAlign.xlVAlignTop
        Me.Styles(i).HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft
        Me.Styles(i).FormulaHidden = True
        Globals.Sheet1.Range("A" & i).Value2 = _
            "Adjusted style " & Me.Styles(i).Name
    Next i
End Sub
private void SetWorkbookStyles()
{
    for (int i = 1; i <= this.Styles.Count; i+)
    {
        this.Styles[i].WrapText = true;
        this.Styles[i].VerticalAlignment = Excel.XlVAlign.xlVAlignTop;
        this.Styles[i].HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
        this.Styles[i].FormulaHidden = true;
        Globals.Sheet1.Range["A" + i, missing].Value2 =
            "Adjusted style " + this.Styles[i].Name;
    }
}

.NET Framework Security

See Also

Reference

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace