IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Paramatrage de la zone Plot area d'un graphique


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de Nono Sto
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    350
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 350
    Par défaut Paramatrage de la zone Plot area d'un graphique
    Chères amies, chers amis du forum

    Grâce à l'enregistreur de macro j'ai pu déterminer les paramètre de ma zone plot area de mon graphe. Je les 'ai ensuite integrer dans ma sub mais rien à faire, j'ai toujours droit à une présentation aléatoire.

    J'ai essayé de mettre mon bout de code à plusieurs endroit car je pense qu'Excel reconfigure automatiquement le graph, mais impossible de fixer mes parametre (il se trouve a l'intérieur d'une structure With ActiveChart)

    voici le bout de code:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    .PlotArea.Height = 627
            .PlotArea.Width = 505
            .PlotArea.Left = 19
            .PlotArea.Top = 36
    et voici le code pour mon graph:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    With ActiveChart
     
            .HasTitle = True
            .Axes(xlCategory).HasTitle = True
            .Axes(xlValue).HasTitle = True
     
            .PlotArea.Interior.ColorIndex = 2
            .PlotArea.Border.LineStyle = xlNone
     
            color = 51
     
       'ici se trouve l'initialisation des .series.collection
     
            .ChartTitle.Font.Name = "Arial Narrow"
            .ChartTitle.Font.Size = 15
            .ChartTitle.Font.Bold = True
            .ChartTitle.Font.Italic = True
            .ChartTitle.Left = .ChartArea.Left
     
            .Axes(xlCategory).AxisTitle.Characters.Text = "Dates"
            .Axes(xlCategory).AxisTitle.Font.Name = "Arial Narrow"
            .Axes(xlCategory).AxisTitle.Font.Size = 10
            .Axes(xlCategory).AxisTitle.Font.Bold = True
            .Axes(xlCategory).AxisTitle.Font.Italic = True
     
            .Axes(xlValue).AxisTitle.Font.Name = "Arial Narrow"
            .Axes(xlValue).AxisTitle.Font.Size = 10
            .Axes(xlValue).AxisTitle.Font.Bold = True
            .Axes(xlValue).AxisTitle.Font.Italic = True
     
            .Axes(xlValue).HasMajorGridlines = True
            .Axes(xlCategory).HasMajorGridlines = True
            .Axes(xlValue).MajorGridlines.Border.LineStyle = xlDot
            .Axes(xlCategory).MajorGridlines.Border.LineStyle = xlDot
     
            .Axes(xlValue).TickLabels.Font.Name = "Arial Narrow"
            .Axes(xlValue).TickLabels.Font.Size = 7
     
            .Axes(xlCategory).TickLabels.Font.Name = "Arial Narrow"
            .Axes(xlCategory).TickLabels.Font.Size = 7
            .Axes(xlCategory).TickLabels.NumberFormat = "d/m/yy;@"
     
            .Axes(xlValue).MinimumScaleIsAuto = True
            .Axes(xlValue).MaximumScaleIsAuto = True
     
            .Axes(xlValue, xlPrimary).AxisTitle.Font.Name = "Arial Narrow"
            .Axes(xlValue, xlPrimary).TickLabels.Font.Name = "Arial Narrow"
            .Axes(xlValue, xlPrimary).TickLabels.Font.Size = 7
            .Axes(xlValue, xlPrimary).AxisTitle.Font.Size = 10
            .Axes(xlValue, xlPrimary).AxisTitle.Font.Bold = True
            .Axes(xlValue, xlPrimary).AxisTitle.Font.Italic = True
     
            .Legend.Font.Name = "Arial Narrow"
            .Legend.Font.Size = 5
            .Legend.Border.LineStyle = xlNone
            .Legend.Position = xlLegendPositionBottom
     
            .PlotArea.Height = 627
            .PlotArea.Width = 505
            .PlotArea.Left = 19
            .PlotArea.Top = 36
     
        End With
    Y a-t-il un moyen de fixer définitivement mes paramètre

    Merci

    NB: bizarrement pas à pas le code s'effectue correctement

  2. #2
    Membre éclairé Avatar de Nono Sto
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    350
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 350
    Par défaut
    J'ai trouver le probleme, en fait à un moment je rentre des parametre qui rendent le graph trop grand, alors Excel corrige avec des valeurs aléatoire le reste des parametre, voici le code qui fonctionne bien:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    Set MonGraphe = ThisWorkbook.Charts.Add
     
    MonGraphe.ChartType = xlLineMarkers
    MonGraphe.Location xlLocationAsObject, "Template"
     
        With Worksheets("Template").ChartObjects(1)
            .Left = Worksheets("Template").Cells(3, 8).Left
            .Top = Worksheets("Template").Cells(3, 8).Top
            .Height = 804
            .Width = 539
        End With
     
     
     
        With ActiveChart
     
            .HasTitle = True
            .Axes(xlCategory).HasTitle = True
            .Axes(xlValue).HasTitle = True
     
             Select Case compteur_page
                Case Is = 2
                    .ChartTitle.Characters.Text = "Evolution des cours"
                Case Is = 3
                    .ChartTitle.Characters.Text = "Evolution des rendements"
                Case Is = 4
                    .ChartTitle.Characters.Text = "Evolution base 100"
            End Select
     
            .ChartTitle.Font.Name = "Arial Narrow"
            .ChartTitle.Font.Bold = True
            .ChartTitle.Font.Italic = True
            .ChartTitle.Left = .ChartArea.Left
            .ChartTitle.Font.Size = 15
     
            .Axes(xlCategory).AxisTitle.Characters.Text = "Dates"
            .Axes(xlCategory).AxisTitle.Font.Name = "Arial Narrow"
            .Axes(xlCategory).AxisTitle.Font.Bold = True
            .Axes(xlCategory).AxisTitle.Font.Italic = True
     
            Select Case compteur_page
                Case Is = 2
                    .Axes(xlValue).AxisTitle.Characters.Text = "Cours"
                Case Is = 3
                    .Axes(xlValue).AxisTitle.Characters.Text = "Rendements"
                Case Is = 4
                    .Axes(xlValue).AxisTitle.Characters.Text = "Cours base 100"
            End Select
     
            .Axes(xlValue).AxisTitle.Font.Name = "Arial Narrow"
            .Axes(xlValue).AxisTitle.Font.Bold = True
            .Axes(xlValue).AxisTitle.Font.Italic = True
     
            .Axes(xlValue).HasMajorGridlines = True
            .Axes(xlCategory).HasMajorGridlines = True
            .Axes(xlValue).MajorGridlines.Border.LineStyle = xlDot
            .Axes(xlCategory).MajorGridlines.Border.LineStyle = xlDot
     
            .Axes(xlValue).TickLabels.Font.Name = "Arial Narrow"
     
            .Axes(xlCategory).TickLabels.Font.Name = "Arial Narrow"
            .Axes(xlCategory).TickLabels.NumberFormat = "d/m/yy;@"
     
            If compteur_page = 3 Then
                .Axes(xlCategory).TickLabelPosition = xlLow
            End If
     
            .Axes(xlValue).MinimumScaleIsAuto = True
            .Axes(xlValue).MaximumScaleIsAuto = True
     
            .Axes(xlValue, xlPrimary).AxisTitle.Font.Name = "Arial Narrow"
            .Axes(xlValue, xlPrimary).TickLabels.Font.Name = "Arial Narrow"
            .Axes(xlValue, xlPrimary).AxisTitle.Font.Bold = True
            .Axes(xlValue, xlPrimary).AxisTitle.Font.Italic = True
     
            .Legend.Font.Name = "Arial Narrow"
            .Legend.Border.LineStyle = xlNone
            .Legend.Position = xlLegendPositionBottom
     
            .PlotArea.Interior.ColorIndex = 2
            .PlotArea.Border.LineStyle = xlNone
     
            .Legend.Left = 54
            .Legend.Top = 691
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 5
     
            .Axes(xlCategory).AxisTitle.Font.Size = 10
            .Axes(xlCategory).TickLabels.Font.Size = 7
     
            .Axes(xlValue).TickLabels.Font.Size = 7
            .Axes(xlValue).AxisTitle.Font.Size = 10
     
            .PlotArea.Left = 25
            .PlotArea.Top = 50
            .PlotArea.Height = 150
            .PlotArea.Width = 550
     
            color = 51
            l = 0
            For Each MesSeries In .SeriesCollection
                    If Tab_(l) = "CAC 40" And compteur_page = 2 And l <> 0 Then
                        MesSeries.AxisGroup = 2
                        MesSeries.Border.ColorIndex = 3
                        MesSeries.Border.Weight = xlThick
                        MesSeries.MarkerStyle = xlMarkerStyleSquare
                        MesSeries.MarkerBackgroundColorIndex = 3
                        MesSeries.MarkerForegroundColorIndex = 3
                        MesSeries.MarkerSize = 2
                        MesSeries.Name = Tab_(l)
                        .Axes(xlValue, xlSecondary).HasTitle = True
                        .Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "CAC 40"
                        .Axes(xlValue, xlSecondary).AxisTitle.Font.Name = "Arial Narrow"
                        .Axes(xlValue, xlSecondary).TickLabels.Font.Name = "Arial Narrow"
                        .Axes(xlValue, xlSecondary).AxisTitle.Font.Bold = True
                        .Axes(xlValue, xlSecondary).AxisTitle.Font.Italic = True
                        .Axes(xlValue, xlSecondary).TickLabels.Font.Size = 7
                        .Axes(xlValue, xlSecondary).AxisTitle.Font.Size = 10
     
                    Else
                        color = color - 1
                        If Tab_(l) = "CAC 40" Then
                            MesSeries.Border.ColorIndex = 3
                            MesSeries.Border.Weight = xlThick
                            MesSeries.MarkerStyle = xlMarkerStyleSquare
                            MesSeries.MarkerBackgroundColorIndex = 3
                            MesSeries.MarkerForegroundColorIndex = 3
                            MesSeries.MarkerSize = 2
                        Else
                            MesSeries.Border.ColorIndex = color
                            MesSeries.Border.Weight = xlThick
                            MesSeries.MarkerStyle = xlMarkerStyleSquare
                            MesSeries.MarkerBackgroundColorIndex = color
                            MesSeries.MarkerForegroundColorIndex = color
                            MesSeries.MarkerSize = 2
                        End If
                        MesSeries.Name = Tab_(l)
                    End If
                l = l + 1
            Next MesSeries
     
        End With

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2003] Supprimer une zone de texte dans un graphique
    Par Vincent32 dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 03/04/2012, 16h52
  2. [PPT-2003] ajouter unez zone de texte dans un graphique msgraph
    Par TomTom2000 dans le forum VBA PowerPoint
    Réponses: 2
    Dernier message: 10/12/2009, 16h03
  3. Zone réactive area avec image
    Par worldhugo dans le forum Balisage (X)HTML et validation W3C
    Réponses: 4
    Dernier message: 28/08/2009, 10h24
  4. [XL-2000] [VBA] Ajout d'une Zone de texte dans un graphique
    Par popsmelove dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 09/04/2009, 18h08
  5. largeur de zone de texte dans les graphiques
    Par 20100. dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 27/09/2008, 18h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo