Partager via


WorksheetBase.Index, propriété

Obtient le numéro d'index de la feuille de calcul dans la collection de feuilles de calcul.

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

Syntaxe

'Déclaration
Public ReadOnly Property Index As Integer
public int Index { get; }

Valeur de propriété

Type : System.Int32
Le numéro d'index de la feuille de calcul dans la collection de feuilles de calcul.

Exemples

L'exemple de code suivant utilise la propriété Index pour afficher le numéro d'index de la feuille de calcul active avant et après avoir déplacé la feuille de calcul à la dernière position dans le classeur à l'aide de la méthode Move.

Cet exemple illustre une personnalisation au niveau du document.

Private Sub DisplayIndex()
    MsgBox("Before moving, this worksheet is at tab number " & _
        Me.Index.ToString())

    ' Move the worksheet to the last position in the workbook.
    Me.Move(After:=Globals.ThisWorkbook.Worksheets( _
        Globals.ThisWorkbook.Worksheets.Count))

    MsgBox("After moving, this worksheet is at tab number " & _
        Me.Index.ToString())
End Sub
private void DisplayIndex()
{
    MessageBox.Show("Before moving, this worksheet is at tab number " +
        this.Index.ToString());

    // Move the worksheet to the last position in the workbook.
    this.Move(missing, 
        Globals.ThisWorkbook.Worksheets[Globals.ThisWorkbook.Worksheets.Count]);

    MessageBox.Show("After moving, this worksheet is at tab number " +
        this.Index.ToString());
}

Sécurité .NET Framework

Voir aussi

Référence

WorksheetBase Classe

Microsoft.Office.Tools.Excel, espace de noms