passage de excel 2003 à 2010 methode "add " de l'objet chartobjects a échoué

MathildeQ

XLDnaute Nouveau
Bonjour,
j'avais une macro de création de graphique qui fonctionnait sous excel 2003 et avec la migration vers excel 2010 celle-ci ne fonctionne plus.
Je précise que tous mes documents s'enregistrent en mode compatibilité excel 2003.
Voici la macro :
Code:
Sub mise_en_forme_effet()
Dim ch As ChartObject
   mois = InputBox("Entrez le mois à traiter (1 à 12) :", "mois de traitement", "01")
    annee = InputBox("Entrez l'année à traiter (aaaa) :", "année de traitement", "2012")
Dim Ws As Worksheet
    For Each Ws In Worksheets
        Ws.Select

    'creation du graphique
   
        Range("B2:m11,B14:m21").Select
Set ch = ActiveSheet.ChartObjects.Add(100, 30, 400, 250)
ch.Chart.SetSourceData Source:=ActiveSheet.Range("B2:m11,B13:m21")
 ch.Chart.ChartType = xlColumnStacked
   
  'mise en forme et page graphique
    ActiveSheet.ChartObjects("Graphique 1").Activate
    ActiveChart.ChartArea.Select
    ActiveSheet.Shapes("Graphique 1").IncrementLeft 30#
    ActiveSheet.Shapes("Graphique 1").IncrementTop 326#
    Windows("decomposition_effet" & mois & annee & ".XLS").SmallScroll Down:=12
       ActiveSheet.Shapes("Graphique 1").ScaleWidth 2.12, msoFalse, _
        msoScaleFromTopLeft
    ActiveChart.Legend.Select
    With Selection.Border
        .Weight = xlHairline
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.Interior.ColorIndex = xlNone
    Selection.Position = xlBottom
    ActiveChart.PlotArea.Select
    With Selection.Border
        .ColorIndex = 16
        .Weight = xlThin
        .LineStyle = xlContinuous
    End With
    Selection.Interior.ColorIndex = xlNone
    ActiveChart.Axes(xlValue).Select
    With ActiveChart.Axes(xlValue)
        .MinimumScaleIsAuto = True
        .MaximumScaleIsAuto = True
        .MinorUnitIsAuto = True
        .MajorUnitIsAuto = True
        .Crosses = xlMaximum
        .ReversePlotOrder = False
        .ScaleType = xlLinear
        .DisplayUnit = xlNone
    End With
    ActiveChart.ChartArea.Select
    Selection.AutoScaleFont = True
    With Selection.Font
        .Name = "Arial"
        .Size = 9
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .Background = xlAutomatic
    End With
    ActiveChart.SeriesCollection(1).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 37
        .Pattern = xlSolid
    End With
    ActiveChart.SeriesCollection(2).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 22
        .Pattern = xlSolid
    End With
    
    
    ActiveChart.SeriesCollection(3).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 3
        .Pattern = xlSolid
    End With
    
        ActiveChart.SeriesCollection(4).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 55
        .Pattern = xlSolid
    End With
    
            ActiveChart.SeriesCollection(5).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 6
        .Pattern = xlSolid
    End With
    
        ActiveChart.SeriesCollection(6).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 36
        .Pattern = xlSolid
    End With
    
        ActiveChart.SeriesCollection(7).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 43
        .Pattern = xlSolid
    End With
    
    ActiveChart.SeriesCollection(8).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 4
        .Pattern = xlSolid
    End With
    
ActiveChart.SeriesCollection(10).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 17
        .Pattern = xlSolid
    End With
    
     ActiveChart.SeriesCollection(9).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 45
        .Pattern = xlSolid
    End With
    
    
    
    
    
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
  
    ActiveChart.Axes(xlValue).MajorGridlines.Select
    With Selection.Border
        .ColorIndex = 15
        .Weight = xlHairline
        .LineStyle = xlContinuous
    End With
    ActiveChart.PlotArea.Select
    With ActiveChart.Axes(xlCategory)
        .HasMajorGridlines = True
        .HasMinorGridlines = False
    End With
    With ActiveChart.Axes(xlValue)
        .HasMajorGridlines = True
        .HasMinorGridlines = False
    End With
    ActiveChart.Axes(xlValue).MajorGridlines.Select
    ActiveChart.Axes(xlCategory).MajorGridlines.Select
    With Selection.Border
        .ColorIndex = 15
        .Weight = xlHairline
        .LineStyle = xlContinuous
    End With
    ActiveChart.Axes(xlCategory).Select
    With Selection.Border
        .ColorIndex = 15
        .Weight = xlHairline
        .LineStyle = xlDot
    End With
    With Selection
        .MajorTickMark = xlOutside
        .MinorTickMark = xlNone
        .TickLabelPosition = xlNextToAxis
    End With
    
     ActiveSheet.Shapes("Graphique 1").IncrementLeft -110.5
    ActiveSheet.Shapes("Graphique 1").IncrementTop 38.25
    Windows("decomposition_effet" & mois & annee & ".XLS").SmallScroll ToRight:=10
    ActiveSheet.Shapes("Graphique 1").ScaleWidth 0.74, msoFalse, _
        msoScaleFromTopLeft
    Windows("decomposition_effet" & mois & annee & ".XLS").ScrollColumn = 4
    Windows("decomposition_effet" & mois & annee & ".XLS").ScrollColumn = 3
    Windows("decomposition_effet" & mois & annee & ".XLS").ScrollColumn = 2
    Windows("decomposition_effet" & mois & annee & ".XLS").SmallScroll Down:=9
    ActiveSheet.Shapes("Graphique 1").ScaleHeight 1.08, msoFalse, _
        msoScaleFromTopLeft
    ActiveChart.Legend.Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlNone
    End With
    Selection.Shadow = False
    Selection.Interior.ColorIndex = xlNone
    
    
    'on ajuste la mise en page à 1page
    With ActiveSheet.PageSetup
    .Zoom = False
    .FitToPagesTall = 1
    .FitToPagesWide = 1
End With

    Range("J27").Select
      Next Ws
End Sub

Je vous remercie pour votre aide.
 

Discussions similaires

Membres actuellement en ligne

Aucun membre en ligne actuellement.

Statistiques des forums

Discussions
312 105
Messages
2 085 350
Membres
102 870
dernier inscrit
Armisa