Chart.Location(XlChartLocation, Object) Méthode

Définition

Déplace le contrôle Chart vers un nouvel emplacement.

public Microsoft.Office.Interop.Excel.Chart Location (Microsoft.Office.Interop.Excel.XlChartLocation Where, object Name);
abstract member Location : Microsoft.Office.Interop.Excel.XlChartLocation * obj -> Microsoft.Office.Interop.Excel.Chart
Public Function Location (Where As XlChartLocation, Optional Name As Object) As Chart

Paramètres

Where
XlChartLocation

XlChartLocation. Emplacement où déplacer le graphique.

Name
Object

Nom de la feuille dans laquelle le graphique est incorporé si Where est xlLocationAsObject ou nom de la nouvelle feuille si Where est xlLocationAsNewSheet.

Retours

Exemples

L’exemple de code suivant crée un Chart , puis utilise la Location méthode pour déplacer le graphique vers une nouvelle feuille nommée « Ventes ».

private void MoveChartToNewSheet()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    Microsoft.Office.Tools.Excel.Chart chart1 =
        this.Controls.AddChart(this.Range["D2", "H12"], 
        "chart1");

    chart1.SetSourceData(this.Range["A1", "B5"], 
        Excel.XlRowCol.xlColumns);
    chart1.ChartType = Excel.XlChartType.xl3DColumn;

    chart1.Location(Excel.XlChartLocation.xlLocationAsNewSheet, 
        "Sales");
}
Private Sub MoveChartToNewSheet()
    Me.Range("A1", "A5").Value2 = 22
    Me.Range("B1", "B5").Value2 = 55

    Dim Chart1 As Microsoft.Office.Tools.Excel.Chart = _
        Me.Controls.AddChart(Me.Range("D2", "H12"), "Chart1")

    Chart1.SetSourceData(Me.Range("A1", "B5"), Excel.XlRowCol.xlColumns)
    Chart1.ChartType = Excel.XlChartType.xl3DColumn

    Chart1.Location(Excel.XlChartLocation.xlLocationAsNewSheet, "Sales")
End Sub

Remarques

Si vous souhaitez déplacer un graphique vers une autre position sur une feuille, utilisez la propriété et Left la Top propriété de .ChartArea Vous pouvez obtenir l’objet ChartArea du à l’aide Chart de la ChartArea propriété .

Paramètres facultatifs

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

S’applique à