Graphique : Erreur code VBA sur Excel 2007 alors fonctionnant parfaitement sur 2003

Malka

XLDnaute Occasionnel
Bonsoir,

Je suis vraiment coincée ce soir sur mon application que j'ai développé sur la version Excel 2003 pour plusieurs utilisateurs...
Or une partie des utilisateurs sont sur Excel 2003 et d'autres sur Excel 2007. :mad:

Tout fonctionne à merveille sur mon excel 2003 mais ca bloque sur la genération des graphiques dont voici le code que j'utilise :

VB:
Sub GraphiquePrincipale()

Application.ScreenUpdating = False

'Demasquage des sheets masquées
Sheets("Winshuttle").Visible = True
Sheets("WinshuttleCléImmo").Visible = True
Sheets("ClésDistribution").Visible = True
Sheets("UO CP").Visible = True
Sheets("UO CC").Visible = True
Sheets("UO OI").Visible = True
Sheets("UO RE").Visible = True
Sheets("Paramètres").Visible = True





    y = ActiveCell.Row
    
  
 'Construction du premier graphique
    Range("I" & y, "T" & y).Copy
    Sheets("Paramètres").Select
    Range("I2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("UO").Select
    Application.CutCopyMode = False
    Sheets("Paramètres").Select
    CelluleVide = WorksheetFunction.CountBlank(Range("I2:T2"))
       If CelluleVide <> 0 Then
    Range("G2").Select
    Selection.Copy
    Range("I2:T2").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
       End If
       
    Sheets("UO").Select
    Range("W" & y, "AH" & y).Copy
    Sheets("Paramètres").Select
    Range("I3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("UO").Select
    Application.CutCopyMode = False
    Sheets("Paramètres").Select
    CelluleVide = WorksheetFunction.CountBlank(Range("I3:T3"))
       If CelluleVide <> 0 Then
    Range("G3").Select
    Selection.Copy
    Range("I3:T3").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
       End If
       

    Sheets("UO").Select
    Range("AK" & y, "AV" & y).Copy
    Sheets("Paramètres").Select
    Range("I4").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("UO").Select
    Application.CutCopyMode = False
    Sheets("Paramètres").Select
    CelluleVide = WorksheetFunction.CountBlank(Range("I4:T4"))
       If CelluleVide <> 0 Then
        Range("G4").Select
    Selection.Copy
    Range("I4:T4").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
        End If
    

    Sheets("UO").Select
    Range("BF" & y, "BQ" & y).Copy
    Sheets("Paramètres").Select
    Range("I5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("UO").Select
    Application.CutCopyMode = False
    Sheets("Paramètres").Select
    CelluleVide = WorksheetFunction.CountBlank(Range("I5:T5"))
       If CelluleVide <> 0 Then
    Range("G5").Select
    Selection.Copy
    Range("I5:T5").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
            End If

'Ajout du nouveau graphique (premier)
    
    
    Charts.Add
    ActiveChart.ChartType = xlLineMarkers
    ActiveChart.SetSourceData Source:=Sheets("Paramètres").Range("H1:T1,H2:T5") _
        , PlotBy:=xlRows
   
    ActiveChart.Location Where:=xlLocationAsObject, Name:="UO"
    
    With ActiveChart
        .HasTitle = False
        .Axes(xlCategory, xlPrimary).HasTitle = False
        .Axes(xlValue, xlPrimary).HasTitle = True
        .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Montant en €"
    End With
    
    ActiveChart.ChartArea.Select
    With ActiveChart
        .HasTitle = True
        .ChartTitle.Characters.Text = Application.Trim(Range("C" & y)) & " / " & Application.Trim(Range("B" & y))
    End With
    
         
    With ActiveChart.Axes(xlCategory)
        .HasMajorGridlines = True
        .HasMinorGridlines = False
    End With
    With ActiveChart.Axes(xlValue)
        .HasMajorGridlines = True
        .HasMinorGridlines = False
    End With
    ActiveChart.HasDataTable = False
    ActiveChart.Axes(xlValue).MajorGridlines.Select
    With Selection.Border
        .ColorIndex = 17
        .Weight = xlHairline
        .LineStyle = xlDot
    End With
    ActiveChart.Axes(xlCategory).MajorGridlines.Select
    With Selection.Border
        .ColorIndex = 17
        .Weight = xlHairline
        .LineStyle = xlDot
    End With
    ActiveChart.PlotArea.Select
    With Selection.Border
        .ColorIndex = 57
        .Weight = xlThin
        .LineStyle = xlContinuous
    End With
    Selection.Interior.ColorIndex = xlNone
    ActiveChart.SeriesCollection(1).Select
    With Selection.Border
        .ColorIndex = 57
        .Weight = xlThick
        .LineStyle = xlContinuous
    End With
    With Selection
        .MarkerBackgroundColorIndex = xlAutomatic
        .MarkerForegroundColorIndex = xlAutomatic
        .MarkerStyle = xlAutomatic
        .Smooth = False
        .MarkerSize = 9
        .Shadow = False
    End With
    
    ActiveChart.Axes(xlCategory).Select
    With Selection.TickLabels
        .Alignment = xlCenter
        .Offset = 100
        .ReadingOrder = xlContext
        .Orientation = xlUpward
    End With
    
     'Carateristiques de la deuxieme serie du premier graphique
    ActiveChart.SeriesCollection(2).Select
    With Selection.Border
        .ColorIndex = 50
        .Weight = xlThick
        .LineStyle = xlContinuous
    End With
    With Selection
        .MarkerBackgroundColorIndex = 50
        .MarkerForegroundColorIndex = 50
        .MarkerStyle = xlSquare
        .Smooth = False
        .MarkerSize = 5
        .Shadow = False
    End With
    ActiveChart.ChartArea.Select

     'Carateristiques de la troisieme serie du premier graphique
    ActiveChart.SeriesCollection(3).Select
    With Selection.Border
        .ColorIndex = 15
        .Weight = xlThick
        .LineStyle = xlContinuous
    End With
    With Selection
        .MarkerBackgroundColorIndex = 15
        .MarkerForegroundColorIndex = 15
        .MarkerStyle = xlSquare
        .Smooth = False
        .MarkerSize = 5
        .Shadow = False
    End With
    ActiveChart.ChartArea.Select

     'Carateristiques de la quatrieme serie du premier graphique
    ActiveChart.SeriesCollection(4).Select
    With Selection.Border
        .ColorIndex = 45
        .Weight = xlThick
        .LineStyle = xlContinuous
    End With
    With Selection
        .MarkerBackgroundColorIndex = 45
        .MarkerForegroundColorIndex = 45
        .MarkerStyle = xlSquare
        .Smooth = False
        .MarkerSize = 5
        .Shadow = False
    End With
    ActiveChart.ChartArea.Select




With Sheets("UO").ChartObjects(1)
.Top = Range("BF" & y + 2).Top
.Left = Range("AZ" & y).Left
End With
  


Range("AZ" & y).Select



'Masquage des sheets masquées
Sheets("Winshuttle").Visible = False
Sheets("WinshuttleCléImmo").Visible = False
Sheets("ClésDistribution").Visible = False
Sheets("UO CP").Visible = False
Sheets("UO CC").Visible = False
Sheets("UO OI").Visible = False
Sheets("UO RE").Visible = False
Sheets("Paramètres").Visible = False



Application.ScreenUpdating = True


End Sub

La macro bloque sur la ligne
.HasTitle = False

J'ai l'impression qu'il ne reconnait pas ce code sur la version 2007 :confused:


Je suis désesperrée car je dois déployer cette application demain.... :(

Si quelqu'un aurait une idée pour me sortir de ce probleme. Je cherche un code qui peut marcher sur les 2 versions d'excel. :eek:

Sinon, j'ai programmé sur Excel 2003.... je ne pensais pas que j'aurai des problemes sur 2007.

Merci beaucoup :rolleyes:

Malka
 
Dernière édition:

hbenalia

XLDnaute Occasionnel
Re : Graphique : Erreur code VBA sur Excel 2007 alors fonctionnant parfaitement sur 2

Bonjour à tous,

J'ai créé un fichier (avec toutes les feuilles necéssaires) où j'ai inséré la macro, l'exécution de la macro dans les deux versions 2003 et 2007 n'a posé aucun problème... Je n'ai aucune explication à ton problème...

Cordialement
 
Dernière édition:

Malka

XLDnaute Occasionnel
Re : Graphique : Erreur code VBA sur Excel 2007 alors fonctionnant parfaitement sur 2

Bonjour

Merci d'avoir essayé le code mais je te confirme bien que j'ai toujours la meme erreur sur cette meme ligne et j'ai essayé mon fichier excel sur 3 postes differents avec excel 2007.... Je pense que tu dois avoir un parametre particulier que je n'ai pas activé dans mon excel 2007 (tables de references dans VBA par exemple....)

Je rappelle que le code bloque sur ces lignes de code :
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Montant en €"
End With

Avec le message d'erreur suivant :
"Erreur d'exécution '-2147467259 (80004005)':
La methode "HasTitle' de l'objet 'Axis' a échoué"



Si d'autres personnes ont d'autres idées pour m'en sortir , je suis preneuse car je suis vraiment dans la m**de



Merci pour toute aide

Malka
 

Discussions similaires

Réponses
2
Affichages
80
Réponses
5
Affichages
54

Statistiques des forums

Discussions
311 725
Messages
2 081 947
Membres
101 849
dernier inscrit
florentMIG