Bonjour tout le monde !
Je suis face à une problème et je compte sur vous pour m'aider à le résoudre
J'ai écrit une macro afin de transformer un graphique d'une feuille excel en image, et d'enregistrer cette image en format .gif et en format .jpg sur mon disque dur. J'ai donc 2 fichiers images qui sont créés par graphique.
Maintenant je souhaiterai contrôler la taille de l'image créé en format .jpg, afin d'avoir une image plus grande que celle enregistré par défaut en format .gif.
Savez-vous comment procéder ?
Je précise que je suis totalement novice en VBA... Ci dessous ma macro qui me créé bien 2 fichiers images par graphique excel, manque plus qu'à rajouter la ligne de code pour controler la taille du fichier .jpg, c'est là que j'ai besoin d'aide !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Sub ExportChart() ' Export a selected chart as a picture Const sSlash$ = "/" Const sPicTypeJPG$ = ".jpg" Const sPicTypeGIF$ = ".gif" Dim sChartName$ Dim sPath$ Dim sBook$ Dim objChart As ChartObject On Error Resume Next ' Test if there are even any embedded charts on the activesheet ' If not, let the user know Set objChart = ActiveSheet.ChartObjects(1) If objChart Is Nothing Then MsgBox "No charts have been detected on this sheet", 0 Exit Sub End If ' Test if there is a single chart selected If ActiveChart Is Nothing Then MsgBox "You must select a single chart for exporting ", 0 Exit Sub End If sChartName = Left(ActiveWorkbook.Name, 6) & "-trend" ' Test for Cancel button If sChartName = "False" Then Exit Sub End If ' If a name was given, chart is exported as a picture in the same ' folder location as their current file sBook = ActiveWorkbook.Path sPathGIF = sBook & sSlash & sChartName & sPicTypeGIF sPathJPG = sBook & sSlash & sChartName & sPicTypeJPG ActiveChart.Export Filename:=sPathGIF, FilterName:="GIF" ActiveChart.Export Filename:=sPathJPG, FilterName:="JPG" End Sub
Merci !!
Partager