NamedRange.Cut, méthode

Coupe le contenu du contrôle NamedRange vers le Presse-papiers ou le colle à un endroit spécifié.

Espace de noms :  Microsoft.Office.Tools.Excel
Assembly :  Microsoft.Office.Tools.Excel (dans Microsoft.Office.Tools.Excel.dll)

Syntaxe

'Déclaration
Function Cut ( _
    Destination As Object _
) As Object
Object Cut(
    Object Destination
)

Paramètres

  • Destination
    Type : System.Object
    Plage dans laquelle les données doivent être collées.Si cet argument est omis, l'objet est coupé, puis placé dans le Presse-papiers.

Valeur de retour

Type : System.Object

Notes

Paramètres optionnels

Pour plus d'informations sur les paramètres optionnels, consultez Paramètres optionnels dans les solutions Office.

Exemples

L'exemple de code suivant utilise la méthode Find pour rechercher la première cellule contenant la valeur Seashell dans un contrôle NamedRange.L'exemple utilise ensuite les méthodes FindNext et FindPrevious pour rechercher la cellule suivante contenant la valeur Seashell puis retourner à la cellule d'origine.Enfin, il utilise la méthode Cut pour couper le contenu de la première cellule contenant la valeur Seashell et le coller dans la cellule B1.

Cet exemple illustre une personnalisation au niveau du document.

    Private Sub FindValue()
        Me.Range("A1").Value2 = "Barnacle"
        Me.Range("A2").Value2 = "Seashell"
        Me.Range("A3").Value2 = "Star Fish"
        Me.Range("A4").Value2 = "Seashell"
        Me.Range("A5").Value2 = "Clam Shell"

        Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
            = Me.Controls.AddNamedRange(Me.Range("A1", "A5"), _
            "namedRange1")

        ' Find the first occurrence of "Seashell".
        Dim Range1 As Excel.Range = namedRange1.Find("Seashell", , , _
            Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByColumns, _
            Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, _
            False, False, )

        ' Find the next occurrence of "Seashell".
        Range1 = namedRange1.FindNext(Range1)

        ' Return to the first occurrence of "Seashell".
        Range1 = namedRange1.FindPrevious(Range1)

        ' Cut the range with the first "Seashell" and copy it to cell B1.
        Dim namedRange2 As Microsoft.Office.Tools.Excel.NamedRange _
            = Me.Controls.AddNamedRange(Range1, "namedRange2")
        namedRange2.Cut(Me.Range("B1"))
    End Sub

private void FindValue()
{
    this.Range["A1"].Value2 = "Barnacle";
    this.Range["A2"].Value2 = "Seashell";
    this.Range["A3"].Value2 = "Star Fish";
    this.Range["A4"].Value2 = "Seashell";
    this.Range["A5"].Value2 = "Clam Shell";

    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A5"],
        "namedRange1");

    // Find the first occurrence of "Seashell".
    Excel.Range Range1 = namedRange1.Find("Seashell",
        Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByColumns,
        Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext,
        false);

    // Find the next occurrence of "Seashell".
    Range1 = namedRange1.FindNext(Range1);

    // Return to the first occurrence of "Seashell".
    Range1 = namedRange1.FindPrevious(Range1);

    // Cut the range with the first "Seashell" and copy it to cell B1.
    Microsoft.Office.Tools.Excel.NamedRange namedRange2 =
        this.Controls.AddNamedRange(Range1, "namedRange2");
    namedRange2.Cut(this.Range["B1"]);
}

Sécurité .NET Framework

Voir aussi

Référence

NamedRange Interface

Microsoft.Office.Tools.Excel, espace de noms