bonjour,
j'avais mis au point il y a quelques temps sous Excel 2000 une macro qui convertissait un tableau, sélectionné avec la souris, en image.
Je suis passé sous Excel 2007 il y a 1 semaine et la macro ne fonctionne plus
Merci beaucoup pour votre (future) aide
Cdt
jll
Voici la macro :
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
| Sub creationImage()
'// Création d'une image bitmap
ActiveSheet.OLEObjects.Add(ClassType:="Paint.Picture", Link:=False, _
DisplayAsIcon:=False).Activate
ActiveSheet.Shapes(1).Name = "test"
ActiveSheet.Shapes("test").Select
Selection.ShapeRange.IncrementLeft 400
Selection.ShapeRange.IncrementTop 400
'// Copie du tableau dans l'image
ActiveSheet.Activate
Range("O2:S27").Select
Selection.Copy
ActiveSheet.Shapes("test").Select
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft 39#
Selection.ShapeRange.IncrementTop 169.5
ActiveSheet.Shapes(2).Name = "image"
ActiveSheet.Shapes("image").Select
ActiveSheet.Shapes("test").Delete
'// Redimensionnement de l'image
b = Selection.ShapeRange.Width
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Width = Selection.ShapeRange.Width * 600 / b
'// Suppression du Copier/coller pour créer un graphe vide
Application.CutCopyMode = False
'// Création d'un graphique
Set Co = ActiveSheet.ChartObjects.Add(0, 0, ActiveSheet.Shapes("image").Width, ActiveSheet.Shapes("image").Height)
'// Copie de l'image dans le graphique et sauvegarde
ActiveSheet.Shapes("image").Copy
With Co.Chart
.Paste
.Export Filename:=ActiveWorkbook.Path & "\testImage.jpg"
End With
Co.Delete
ActiveSheet.Shapes("image").Delete
End Sub |