Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

NamedRange.Characters Property

Gets a Microsoft.Office.Interop.Excel.Characters object that represents a range of characters within the text of the NamedRange control.

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

NamedRange_CharactersType Characters { get; }

Property Value

Type: Microsoft.Office.Tools.Excel.NamedRange_CharactersType
A Microsoft.Office.Interop.Excel.Characters object that represents a range of characters within the text of the NamedRange control.

The Characters property is intended to be used with the following parameters.

Parameter

Description

Start

The first character to be returned. If this argument is either 1 or omitted, this property returns a range of characters starting with the first character.

Length

The number of characters to be returned. If this argument is omitted, this property returns the remainder of the string (everything after the Start character).

If you attempt to use Characters without specifying any parameters, Characters will get a NamedRange_CharactersType object that is part of the Visual Studio infrastructure and is not intended to be used directly from your code.

You can use the Microsoft.Office.Interop.Excel.Characters object to format characters within a text string. The Microsoft.Office.Interop.Excel.Characters object is not a collection.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example creates a NamedRange and populates it with the word Smith. It then changes the first character in the word by making it bold and setting the size to 14.

This version is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange charactersRange;
private void FormatCharacters()
{
    charactersRange = this.Controls.AddNamedRange(
        this.Range["A1", "A1"], "charactersRange");
    this.charactersRange.Value2 = "Smith";
    this.charactersRange.Characters[1, 1].Font.Bold = true;
    this.charactersRange.Characters[1, 1].Font.Size = 14;
}

This version is for an application-level add-in.

Show:
© 2015 Microsoft