How to: Programmatically Apply Styles to Ranges in Workbooks
You can apply named styles to regions in workbooks. Excel supplies a number of predefined styles.
Applies to: The information in this topic applies to document-level projects and VSTO add-in projects for Excel. For more information, see Features Available by Office Application and Project Type.
The Format Cells dialog box displays all the options you can use to format cells, and each of these options is available from your code. To display this dialog box in Excel, click Cells on the Format menu.
To apply a style to a named range in a document-level customization
Create a new style and set its attributes.
Create a NamedRange control, assign text to it, and then apply the new style. This code must be placed in a sheet class, not in the
ThisWorkbookclass.
To clear a style from a named range in a document-level customization
Apply the Normal style to the range. This code must be placed in a sheet class, not in the
ThisWorkbookclass.
To apply a style to a named range in a VSTO Add-in
Create a new style and set its attributes.
Create a Microsoft.Office.Interop.Excel.Range, assign text to it, and then apply the new style.
To clear a style from a named range in an VSTO Add-in
Apply the Normal style to the range.
Working with Ranges
NamedRange Control
Global Access to Objects in Office Projects
Optional Parameters in Office Solutions