Excel 97- problème compilation VBA

Lu Wei

XLDnaute Nouveau
Bonjour à tous,

Je me retrouve avec un logiciel qu'un collègue a implémenté sous Excel VBA et il y a des erreurs, et en particulier une que je n'arrive pas à résoudre.
Lorsque je compile, s'affiche le message d'erreur suivant:

Erreur d'execution '1004'
Impossible de lire la proproété ChartObjects de la classe Worksheet.

De plus, il parle de Graphique 6 mais je ne sais pas auquel graphe cela correspond. Le programme marchait bien avant et là je ne sais pas pourquoi, ça ne compile plus pourtant rien dans le code n'a été changé.

Si quelqu'un a une idée, ça m'aiderait beaucoup. Je vosu remercie d'avance.

Bonne journée

Voilà la petite partie du programme concerné: (l'erreur est en rouge)


Private Sub CommandButton1_Click()
' Remettre les champs à zéro

'CheckBox1.Value = False
'CheckBox2.Value = False
'CheckBox3.Value = False
'CheckBox4.Value = False
'CheckBox5.Value = False
'CheckBox6.Value = False
'CheckBox7.Value = False
'CheckBox8.Value = False
'CheckBox9.Value = False
'CheckBox10.Value = False
'CheckBox12.Value = False

While Not UserForm5.TextBox1.Value = " "

'Sheets("Identification").Visible = True
Sheets("M (2)").Select

'Déverrouiller la feuille
ActiveSheet.Unprotect

Dim i As Integer
Dim j As Integer

i = 8
j = 3
'Boucle sur les cellules de la ligne 5
'On sort de la boucle si la cellule testée (Cells(5, i)) est égale à "Muda chiffon"
Sheets("M (2)").Select
While Not (ActiveSheet.Cells(5, i)) = "0"


'Incrémente la variable d'une unité afin de tester la cellule suivante.
i = i + 1
Wend


'Case trouvée

While Not (ActiveSheet.Cells(j, 8)) = "STOP"
j = j + 1
Wend

Sheets("M (2)").Select
Range(ActiveSheet.Cells(5, 8), ActiveSheet.Cells(j - 1, 8)).Copy


Range(ActiveSheet.Cells(5, i), ActiveSheet.Cells(j - 1, i)).Select
ActiveSheet.Paste
Range(ActiveSheet.Cells(6, i), ActiveSheet.Cells(j - 3, i)).ClearContents 'supprimer juste les valeurs de la colonne 10

ActiveSheet.Cells(5, i) = UserForm5.TextBox1.Value
ActiveSheet.Range(Cells(5, i), (Cells(j - 1, i))).Select


'couleur = InputBox("Choisir la couleur : Vert=4, Cyan=8, Gris=15, Violet=17, Jaune pâle=19, Cyan clair=20, Violet clair=24, Vert pâle=35, Bleu clair=33, Vert clair=43")

If CheckBox1.Value = True Then
couleur = 46
CheckBox1.Value = False
End If
If CheckBox2.Value = True Then
couleur = 45
CheckBox2.Value = False
End If
If CheckBox3.Value = True Then
couleur = 8
CheckBox3.Value = False
End If
If CheckBox4.Value = True Then
couleur = 15
CheckBox4.Value = False
End If
If CheckBox5.Value = True Then
couleur = 17
CheckBox5.Value = False
End If
If CheckBox6.Value = True Then
couleur = 19
CheckBox6.Value = False
End If
If CheckBox7.Value = True Then
couleur = 20
CheckBox7.Value = False
End If
If CheckBox8.Value = True Then
couleur = 24
CheckBox8.Value = False
End If
If CheckBox9.Value = True Then
couleur = 35
CheckBox9.Value = False
End If
If CheckBox10.Value = True Then
couleur = 33
CheckBox10.Value = False
End If
If CheckBox12.Value = True Then
couleur = 43
CheckBox12.Value = False
End If
If CheckBox13.Value = True Then
couleur = 6
CheckBox13.Value = False
End If

Selection.Interior.ColorIndex = couleur

' Mise à jour de la feuille Graph4_2
Sheets("Graph4_2").Select
ActiveSheet.Cells(27, i - 8) = UserForm5.TextBox1.Value

ActiveSheet.Cells(27, i - 8).Select
Selection.Interior.ColorIndex = couleur
ActiveSheet.Cells(28, i - 8).Select
Selection.Interior.ColorIndex = couleur
ActiveSheet.Cells(29, i - 8).Select
Selection.Interior.ColorIndex = couleur

' Mise à jour de la feuille Graph4_2 (2)
Sheets("Graph4_2 (2)").Select
ActiveSheet.Cells(27, i - 8) = UserForm5.TextBox1.Value

ActiveSheet.Cells(27, i - 8).Select
Selection.Interior.ColorIndex = couleur
ActiveSheet.Cells(28, i - 8).Select
Selection.Interior.ColorIndex = couleur
ActiveSheet.Cells(29, i - 8).Select
Selection.Interior.ColorIndex = couleur


'changer la couleur du graphe 3 (graphe des antécédents)

Sheets("M (2)").Select
ActiveSheet.ChartObjects("Graphique 3").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(i - 8).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = couleur
.Pattern = xlSolid
End With
' ActiveWindow.Visible = False


'changer la couleur du graphe 4 (Graphe des temps)
ActiveWindow.Visible = False
ActiveSheet.ChartObjects("Graphique 6").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Points(i - 9).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
With Selection.Interior
.ColorIndex = couleur
.Pattern = xlSolid
End With
' ActiveWindow.Visible = False

'changer la couleur du graphe 4 Plein ecran (Graphe des temps)
'Sheets("Graph4 (2)").Visible = True
Sheets("Graph4_2").Select
ActiveSheet.ChartObjects("Graphique 1").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Points(i - 9).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
With Selection.Interior
.ColorIndex = couleur
.Pattern = xlSolid
End With
' Sheets("Graph4").Visible = False


'idem feuille Graph4_2 (2)
Sheets("Graph4_2 (2)").Select
ActiveSheet.ChartObjects("Graphique 1").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Points(i - 9).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
With Selection.Interior
.ColorIndex = couleur
.Pattern = xlSolid
End With

'changer la couleur des Graphiques de la feuille "Résultat MUDA"

Sheets("Résultat MUDA").Select
ActiveSheet.ChartObjects("Graphique 4").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Points(i - 9).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
With Selection.Interior
.ColorIndex = couleur
.Pattern = xlSolid
End With

ActiveSheet.ChartObjects("Graphique 5").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Points(i - 9).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
With Selection.Interior
.ColorIndex = couleur
.Pattern = xlSolid
End With


'Message de validation
'Msg = "Le Muda a bien été ajouté"
'Title = "Etape validée"
'Style = vbOKOnly + vbInformation
'Reponse = MsgBox(Msg, Style, Title)
Sheets("M (2)").Select
'ells(5, i).Select


'Verrouiller
'ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True


'UserForm1.Hide
'Sheets("Identification").Visible = False
UserForm5.TextBox1.Value = " "
Wend
End Sub


Private Sub CommandButton2_Click()

UserForm5.Hide
Sheets("Page_Pilotage").Select

'Mise à jour du smiley
ActiveSheet.Cells(151, 1) = "J"
Cells(1, 1).Select

End Sub




Private Sub userform_initialize()

'UserForm5.TextBox1.Value.Clear
CheckBox1.Value = False
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
CheckBox5.Value = False
CheckBox6.Value = False
CheckBox7.Value = False
CheckBox8.Value = False
CheckBox9.Value = False
CheckBox10.Value = False
CheckBox12.Value = False
UserForm5.TextBox1.Value = " "

End Sub
 

tototiti2008

XLDnaute Barbatruc
Re : Excel 97- problème compilation VBA

Bonjour Lu Wei,

pour retrouver le Graphique 6 (s'il existe encore)
mets toi dans la feuille
dans la zone Nom (à gauche de la barre de formules, là où tu vois les références de cellules), cliques dedans et tapes
Graphique 6
+ Entrée
il devrait sélectionner le graphique
 

Lu Wei

XLDnaute Nouveau
Re : Excel 97- problème compilation VBA

Effectivement le graphe 6 n'existe pas!!! ou plus!!! Je vais essayer de elr echrcher sur l'ancienne version du logiciel que j'ai gardé pour voir lequel c'est mais cela me parait bizarre étant donné que rien n'a changé au niveau de la présentation.

Merci pour l'astuce
 

Statistiques des forums

Discussions
312 207
Messages
2 086 232
Membres
103 161
dernier inscrit
Rogombe bryan