NamedRange.PasteSpecial Method (2007 System)

Pastes the contents of a Range object from the Clipboard into 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
Public Function PasteSpecial ( _
    Paste As XlPasteType, _
    Operation As XlPasteSpecialOperation, _
    SkipBlanks As Object, _
    Transpose As Object _
) As Object
'Usage
Dim instance As NamedRange 
Dim Paste As XlPasteType 
Dim Operation As XlPasteSpecialOperation 
Dim SkipBlanks As Object 
Dim Transpose As Object 
Dim returnValue As Object 

returnValue = instance.PasteSpecial(Paste, _
    Operation, SkipBlanks, Transpose)
public Object PasteSpecial(
    XlPasteType Paste,
    XlPasteSpecialOperation Operation,
    Object SkipBlanks,
    Object Transpose
)
public:
Object^ PasteSpecial(
    XlPasteType Paste, 
    XlPasteSpecialOperation Operation, 
    Object^ SkipBlanks, 
    Object^ Transpose
)
public function PasteSpecial(
    Paste : XlPasteType, 
    Operation : XlPasteSpecialOperation, 
    SkipBlanks : Object, 
    Transpose : Object
) : Object

Parameters

  • SkipBlanks
    Type: System.Object

    true to not have blank cells in the range on the Clipboard pasted into the destination range. The default value is false.

  • Transpose
    Type: System.Object

    true to transpose rows and columns when the range is pasted. The default value is false.

Return Value

Type: System.Object

Remarks

Optional Parameters

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

Examples

The following code example uses the Copy method to copy the contents of a NamedRange control named NamedRange1 to the Clipboard, and then uses the PasteSpecial method to paste these contents into a NamedRange control named NamedRange2. The Operation parameter is set to xlPasteSpecialOperationAdd so that the content of each cell in NamedRange1 is added to the corresponding cell in NamedRange2.

This example is for a document-level customization.

Private Sub CopyAndPasteSpecialRange()
    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1", "A3"), _
        "namedRange1")
    namedRange1.Value2 = 22

    Dim namedRange2 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("C1", "C3"), _
        "namedRange2")
    namedRange2.Value2 = 5

    ' Copy the contents of namedRange1 to the clipboard, and then 
    ' paste the contents into namedRange2, adding each value to 
    ' the value in namedRange2.
    namedRange1.Copy()
    namedRange2.PasteSpecial(Excel.XlPasteType.xlPasteAll, _
    Excel.XlPasteSpecialOperation.xlPasteSpecialOperationAdd, _
    False, False)
End Sub
private void CopyAndPasteSpecialRange()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A3"],
        "namedRange1");
    namedRange1.Value2 = 22;

    Microsoft.Office.Tools.Excel.NamedRange namedRange2 =
        this.Controls.AddNamedRange(this.Range["C1", "C3"],
        "namedRange2");
    namedRange2.Value2 = 5;

    // Copy the contents of namedRange1 to the clipboard, and then 
    // paste the contents into namedRange2, adding each to 
    // the value in namedRange2.
    namedRange1.Copy(missing);
    namedRange2.PasteSpecial(Excel.XlPasteType.xlPasteAll,
        Excel.XlPasteSpecialOperation.xlPasteSpecialOperationAdd,
        false,
        false);
}

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace