Macro bug lors du passage de 2003 à 2010

Bonjour a tous et à toute!

Je suis récemment passé de excel 2003 à 2010. Je dispose d'une macro (pas de moi) qui me permettait de mettre en forme mes résultats. Je ne maitrise pas VB. Or depuis ce passage la macro bug à ce niveau:

   
 'ActiveChart.Location Where:=xlLocationAsObject, Name:="LP " & LLp(Lp)
  ActiveChart.Location Where:=xlLocationAsObject, Name:=LLp(Lp)
   With ActiveChart                                                                                              
    .HasTitle = True 
   .ChartTitle.Characters.Text = TitreG
    .Axes(xlCategory, xlPrimary).HasTitle = False
    .Axes(xlValue, xlPrimary).HasTitle = False
  End With
  With ActiveChart
    .HasAxis(xlCategory, xlPrimary) = True
    .HasAxis(xlValue, xlPrimary) = True
  End With
  ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
  With ActiveChart.Axes(xlCategory)
    .HasMajorGridlines = False
    .HasMinorGridlines = False
  End With
  With ActiveChart.Axes(xlValue)
    .HasMajorGridlines = False
    .HasMinorGridlines = False
  End With
  ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowValue, LegendKey:=False
  ActiveSheet.ChartObjects(1).Name = "Graphe LP"

    ActiveSheet.Shapes("Graphe LP").ScaleWidth 1.5, msoFalse, msoScaleFromBottomRight
'    ActiveSheet.Shapes("Graphe LP").ScaleHeight 0.72, msoFalse, msoScaleFromTopLeft
'    ActiveSheet.Shapes("Graphe LP").ScaleHeight 1.15, msoFalse, msoScaleFromBottomRight
'    ActiveSheet.Shapes("Graphe LP").ScaleWidth 1.84, msoFalse, msoScaleFromTopLeft

'  ActiveSheet.Shapes("Graphe LP").IncrementLeft -190
  ActiveSheet.Shapes("Graphe LP").ScaleWidth Larg, msoFalse, msoScaleFromTopLeft
'  ActiveSheet.Shapes("Graphe LP").IncrementTop -3#

  If Etude <> 6 Then
    'ActiveSheet.Shapes("Graphe LP").ScaleHeight 1.234, msoFalse, msoScaleFromTopLeft
    ActiveSheet.Shapes("Graphe LP").ScaleHeight 0.72, msoFalse, msoScaleFromTopLeft
    ActiveSheet.Shapes("Graphe LP").ScaleHeight 1.15, msoFalse, msoScaleFromBottomRight
  Else
    ActiveSheet.Shapes("Graphique 2").ScaleHeight 0.67, msoFalse, msoScaleFromTopLeft
    ActiveSheet.Shapes("Graphique 2").ScaleHeight 1.22, msoFalse, msoScaleFromBottomRight
    ActiveSheet.Shapes("Graphique 2").ScaleHeight 1.01, msoFalse, msoScaleFromBottomRight
    ActiveSheet.Shapes("Graphique 2").ScaleHeight 1.01, msoFalse, msoScaleFromTopLeft
    'ActiveSheet.Shapes("Graphe LP").ScaleHeight 1.17, msoFalse, msoScaleFromTopLeft
  End If

Je sais qu'il n'est pas facil de repondre sans voir la totalité du code mais celui-ci est confidentiel

Merci de votre aide, dispo si besoin bonne journée!!

Alex

Apres recherche je crois comprendre que :

ActiveChart.Location Where:=xlLocationAsObject, Name:=LLp(Lp)

Me permet de donner l'emplacement de mon graphique et Name qui ici est "salades" correspond a la feuille ou doit etre mon graphe...

Je ne vois donc pas pk excel 2010 ne fonctionne pas à ce niveau

Bonjour

Sans le fichier pas facile, en plus les graphiques c'est quoi ?

Pour essayé de faire avancer le schmilblick

Ton graphique est bien sélectionné ?

Quel est le message d'erreur ?

La feuille existe bien ?

Bonjour Banzai,

Le graphique est un histogramme classique.

Comment selectionner mon graphique?

Le message d'erreur apres debodage est l'identificateur sous le curseur n'est pas reconnu.

La feuille va avoir un nom différent selon le fichier elle est correct ici à l'aide de la méthode du pas a pas je peux voir que LLp(Lp)

est salades nom de ma feuille.

Je test actuellement une autre solution qui est:

  With ActiveChart
    .Name = LLp(Lp)
    .HasTitle = True
    .ChartTitle.Characters.Text = TitreG
    .Axes(xlCategory, xlPrimary).HasTitle = False
    .Axes(xlValue, xlPrimary).HasTitle = False
    .Location Where:=xlLocationAsObject
  End With

Pas concluant débodage au niveau du HasTitle

Merci pour votre aide


PS: Je vous joins la partie au dessus du premier code qui me permet de construire le graphique:

 Sheets(LLp(Lp)).Select
'  Sheets("LP " & LLp(Lp)).Select

  If Etude = 6 Then

'pour libelle graphique
  If NbGroup = 7 Then
    Range("B27:D27").Select
    Selection.UnMerge
    With Selection
        .HorizontalAlignment = xlCenterAcrossSelection
        .VerticalAlignment = xlCenter
    End With
    Range("E27:G27").Select
    Selection.UnMerge
    With Selection
        .HorizontalAlignment = xlCenterAcrossSelection
        .VerticalAlignment = xlCenter
    End With
  End If
  If NbGroup = 5 Then
    Range("B27:C27").Select
    Selection.UnMerge
    With Selection
        .HorizontalAlignment = xlCenterAcrossSelection
        .VerticalAlignment = xlCenter
    End With
    Range("D27:E27").Select
    Selection.UnMerge
    With Selection
        .HorizontalAlignment = xlCenterAcrossSelection
        .VerticalAlignment = xlCenter
    End With
  End If

   If ok2 > 0 Then
    'Set Abscisse = Range(Cells(ok2 - 1, 2), Cells(ok2 - 1, (NbGroup - 1) / 2 + 1))
    'Set abscisse2 = Range(Cells(ok2 - 1, (NbGroup - 1) / 2 + 2), Cells(ok2 - 1, NbGroup))
    'Set Titre = Range(Cells(28, 2), Cells(28, (NbGroup - 1) / 2 + 1))
    TitreG = Cells(ok2 - 1, 1) & " DE LA LIGNE '" & Trim(Cells(28, 1)) & "'"

   Else
    Set Abscisse = Range(Cells(ok1 - 1, 2), Cells(ok1 - 1, (NbGroup - 1) / 2 + 1))
    Set abscisse2 = Range(Cells(ok1 - 1, (NbGroup - 1) / 2 + 2), Cells(ok1 - 1, NbGroup))
    Set Titre = Range(Cells(28, 2), Cells(28, (NbGroup - 1) / 2 + 1))
    TitreG = Cells(ok1 - 1, 1) & " DE LA LIGNE '" & Trim(Cells(28, 1)) & "'"

   End If
    'If LargCol = 8.57 Then Conv = 0.164
    'If LargCol = 8 Then Conv = 0.153

    If LargCol = 8.57 Then Conv = 0.164
    If LargCol = 8 Then Conv = 0.153

    'Larg = 1.01 + (NbGroup - 1) * Conv
    Larg = 0.35 + (NbGroup - 1) * Conv

    If ok2 > 0 Then
     'Range(Cells(ok2 - 1, 1), Cells(ok2 - 1, (NbGroup - 1) / 2 + 1)).Select
    Else
     Range(Cells(ok1 - 1, 1), Cells(ok1 - 1, (NbGroup - 1) / 2 + 1)).Select
    End If
    'Charts.Add
    'ActiveChart.ChartType = xlColumnClustered
    'ActiveChart.SeriesCollection(1).Values = Abscisse
    'ActiveChart.SeriesCollection(1).XValues = Titre
    'ActiveChart.SeriesCollection.NewSeries
    'ActiveChart.SeriesCollection(2).Values = abscisse2
    'ActiveChart.SeriesCollection(2).XValues = Titre

  Else

    i = 29
    OK = 0
    Do While Cells(i, 1) <> "" And OK = 0
     If Ajust = 1 Then
       If (InStr(Trim(Cells(i, 1)), "VMH VALEUR AJUST") = 1 Or _
           InStr(Trim(Cells(i, 1)), "VMM VALEUR AJUST") = 1) Then
         OK = i
       End If
     Else
       If Ajust = 0 Then
         If (InStr(Trim(Cells(i, 1)), "VMH VALEUR") = 1 Or _
             InStr(Trim(Cells(i, 1)), "VMM VALEUR") = 1) Then
           OK = i
         End If
       End If
     End If
     i = i + 1
    Loop

    Set Abscisse = Range(Cells(OK, 2), Cells(OK, NbGroup))
    Set Titre = Range(Cells(28, 2), Cells(28, NbGroup))
    'TitreG = "VMH VALEUR AJUSTEES DE LA LIGNE '" & Trim(Cells(28, 1)) & "'"
    TitreG = Cells(OK, 1) & " DE LA LIGNE '" & Trim(Cells(28, 1)) & "'"

    'If LargCol = 10 Then Conv = 0.19
    If LargCol = 10 Then Conv = 0.19
    'If Largcol = 8 Then Conv = 0.17

    'larg = 1.01 + (NbGroup - 1) * Conv
    Larg = 0.3 + (NbGroup - 1) * Conv

    Range(Cells(OK, 1), Cells(OK, NbGroup)).Select
    Charts.Add
    ActiveChart.ChartType = xlColumnClustered
    ActiveChart.SeriesCollection(1).Values = Abscisse
    ActiveChart.SeriesCollection(1).XValues = Titre

  End If

Je viens de trouver l'erreur: la sécurité de mon excel ... (d'apres mon collegue).... Mais cette macro a tout de meme un soucis et ne veut tjrs pas aller au bout donc je réflechi a mon nouveau soucis!

cordialement

Bonsoir

Je me suis mal exprimé

Banzai64 a écrit :

en plus les graphiques c'est quoi ?

Voulait dire que je n'y connais pratiquement rien dans les graphiques

J'ai essayé de débloquer la situation en posant des questions

Et une nouvelle question arrive

Alex64140 a écrit :

l'identificateur sous le curseur n'est pas reconnu

Sur quelle ligne ?

Donc d'après ce que je comprends la 1ère ligne qui buggait venait du fait que ta page était protégée ?

Juste pour info j'ai essayé un truc comme ça (pour voir)

Sub bb()
Dim TitreG As String
TitreG = "Banzai64"

  Charts.Add After:=Worksheets("Feuil1")
  With ActiveChart
    .Name = "hello"   'LLp(Lp)
    .HasTitle = True
    .ChartTitle.Characters.Text = TitreG
    .Axes(xlCategory, xlPrimary).HasTitle = False
    .Axes(xlValue, xlPrimary).HasTitle = False
    .Location Where:=xlLocationAsObject, Name:="feuil2"
  End With
End Sub

Pas de plantage après avoir ajouté la partie surlignée

Mais sans ton fichier, ou du moins 1 copie, avec ta macro qui plante, je n'irai pas plus loin

Je suis à la limite max avec ce que connais des graphiques

Merci pour votre aide la macro est réparrer pour les pages que l'on désirait.

A titre perso et pour achever completement cette macro il me manque une derniere page qui est peu utilisé par ma boite mes dont je voudrais venir a bout: je vous joins le code ci dessous:

        Sheets("SYNTHESE").Select
        ActiveSheet.Shapes("Drop Down 3").Select
       Selection.OnAction = Macro & "!MarcheCig_QuandChangement"
        With Selection
           .ListFillRange = "'Vues 1'!$A$1:$A$" & i
           .LinkedCell = "'Vues 1'!$D$1"
           .DropDownLines = i
           .Display3DShading = False
        End With
      ActiveSheet.Shapes("Drop Down 4").Select
        Selection.OnAction = Macro & "!MarcheCig_QuandChangement"
       With Selection
            .ListFillRange = "'Vues 2'!$A$1:$A$" & j
            .LinkedCell = "'Vues 2'!$D$1"
            .DropDownLines = j
           .Display3DShading = False
        End With

cette partie fonctionne parfaitement sur les ordis équipés en excel 2003 mais pas ceux de 2010...

Il faut apparament recuperer le nom de mes shapes:

   Worksheets("EDT GENERAL").Shapes(Worksheets("EDT GENERAL").Shapes.Count).Name 
ActiveSheet.Shapes(X).Select 

Si quelqu'un maitrise ce genre de manip !

En tout cas merci de ton aide banzaiii et bonne apres midi a tous

Rechercher des sujets similaires à "macro bug lors passage 2003 2010"