Share via


NamedRange.Resize Property (2007 System)

Gets a resized Range based on the NamedRange control.

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 Resize As NamedRange._ResizeType
'Usage
Dim instance As NamedRange 
Dim value As NamedRange._ResizeType 

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

Property Value

Type: Microsoft.Office.Tools.Excel.NamedRange._ResizeType
A resized Range based on the NamedRange control.

Remarks

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

Parameter

Description

RowSize

The number of rows in the new range. If this argument is omitted, the number of rows in the range remains the same.

ColumnSize

The number of columns in the new range. If this argument is omitted, the number of columns in the range remains the same.

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

Optional Parameters

For information on optional parameters, see The Variable missing and Optional Parameters in Office Solutions.

Examples

The following code example creates a NamedRange and then uses the Resize property to get a larger range based on the NamedRange. The code then selects the new range.

This version is for a document-level customization.

Private resizeRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub CreateResizedRange()
    resizeRange = Me.Controls.AddNamedRange( _
        Me.Range("B2", "C4"), "resizeRange")
    Dim range1 As Excel.Range = Me.resizeRange.Resize(6, 6)
    range1.Select()
End Sub
Microsoft.Office.Tools.Excel.NamedRange resizeRange;
private void CreateResizedRange()
{
    resizeRange = this.Controls.AddNamedRange(
        this.Range["B2", "C4"], "resizeRange");
    Excel.Range range1 = this.resizeRange.Resize[6, 6];
    range1.Select();
}

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

Private resizeRange As NamedRange

Private Sub CreateResizedRange()
    Dim vstoWorksheet As Worksheet = CType( _
        Me.Application.ActiveWorkbook.Worksheets(1),  _
        Excel.Worksheet).GetVstoObject()
    resizeRange = vstoWorksheet.Controls.AddNamedRange( _
        vstoWorksheet.Range("B2", "C4"), "resizeRange")
    Dim range1 As Excel.Range = resizeRange.Resize(6, 6)
    range1.Select()
End Sub
NamedRange resizeRange;
private void CreateResizedRange()
{
    Worksheet vstoWorksheet = ((Excel.Worksheet)
        this.Application.ActiveWorkbook.Worksheets[1]).GetVstoObject();
    resizeRange = vstoWorksheet.Controls.AddNamedRange(
        vstoWorksheet.Range["B2", "C4"], "resizeRange");
    Excel.Range range1 = resizeRange.Resize[6, 6];
    range1.Select();
}

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace

Change History

Date

History

Reason

July 2008

Added a version of the code example for an application-level add-in.

SP1 feature change.