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
| ' Déclarations
Dim PptApp As PowerPoint.Application
Dim PptDoc As PowerPoint.Presentation
Dim PptSlide As PowerPoint.Slide
Dim PptShape As PowerPoint.Shape
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Sub ViderLePressePapier1()
OpenClipboard 0
EmptyClipboard
CloseClipboard
End Sub
Sub ViderLePressePapier2()
On Error Resume Next
Application.CommandBars("Clipboard").Controls(4).Execute
End Sub
Sub MaSub ()
Application.DisplayAlerts = False
Application.CutCopyMode = False
' Ouverture Powerpoint
Set PptApp = New PowerPoint.Application
PptApp.Visible = True
' Ouverture du document powerpoint à modifier
Set PptDoc = PptApp.Presentations.Open(nom_fichier)
' Initialisation de l'index diapo qui marque le début de la copie dans Powerpoint
index_diapo = x
' Pour chaque feuille du classeur
For i = 0 nb_feuilles
' Sélection de la feuille
Sheets(i).Select
' Pour chaque graphique de la feuille
For Each graphique In ActiveSheet.ChartObjects
' Copie le graphique
graphique.Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
' Création d'une nouvelle diapo dans Powerpoint
PptApp.Activate
PptApp.ActiveWindow.ViewType = ppViewSlide
Set PptSlide = PptDoc.Slides.Add(index_diapo, ppLayoutLargeObject)
' Sélection de la zone de la diapo destinée à recevoir le graphique
PptSlide.Select
PptSlide.Shapes(1).Select
' Collage du graphique dans la nouvelle diapo
PptApp.ActiveWindow.View.PasteSpecial (ppPasteMetafilePicture)
' Incrémentation de l'index diapo
index_diapo = index_diapo + 1
Call ViderLePressePapier1
Call ViderLePressePapier2
Next
Next
End Sub |