Erreur "Dimension spécifiée non valide pour le type de graphique en cours"
Bonjour, :)
Soit le code ci-dessous:
Code:
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
| Sub proc()
Dim s As Shape
Dim shDest As Worksheet
Dim i As Integer
Dim ch As Chart
Dim graph As Shape
Dim annee, anneesyg As Integer
anneesyg = Year(Date)
If moissyg = 1 Then
annee = anneesyg - 1
Else
annee = anneesyg
End If
On Error Resume Next
ThisWorkbook.Sheets("Graphes " & annee).Visible = True
If Err.Number > 0 Then
ThisWorkbook.Sheets.Add after:=Sheets(Sheets.Count) ' Création
ActiveSheet.Name = "Graphes " & annee
ActiveWindow.Zoom = 94
Range("A1:Z500").Interior.ColorIndex = 6
End If
On Error GoTo 0
' Feuille de destination
Set shDest = ThisWorkbook.Sheets("Graphes " & annee)
For Each graph In shDest.Shapes
graph.Delete
Next
Application.CutCopyMode = False
Attente.Show vbModeless
For Each ch In Charts
DoEvents
ch.Activate
ch.CopyPicture
shDest.Range("A1").PasteSpecial
Set s = shDest.Shapes(shDest.Shapes.Count)
s.ScaleHeight 0.5, msoTrue
s.ScaleWidth 0.5, msoTrue
s.Left = (i Mod 2) * (s.Width + 50)
s.Top = (Int(i / 2) * (s.Height + 10))
i = i + 1
Next ch
Unload Attente
With Application
.Visible = True
.WindowState = xlMaximized
End With
ThisWorkbook.Save
Unload popupIndicateur
With Sheets("parametres")
.Range("A30").Value = Date
End With
Blok
Sheets("Graphes " & annee).Select
End Sub |
A l'exécution, j'obtiens l'erreur:
Citation:
Dimension spécifiée non valide pour le type de graphique en cours.
L'erreur provient des lignes:
Code:
1 2 3 4 5
| With Sheets("parametres")
.Range("A30").Value = Date
End With |
En effet, en les enlevant, tout fonctionne très bien... Je ne comprends pas le rapport avec l'erreur, une idée pour résoudre cela ?
Merci d'avance.