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
|
Option Explicit
Sub Export_Graphiques_Vers_Word()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim onglet As Worksheet
Dim graphique As Chart
Application.ScreenUpdating = False
Set wrdApp = GetObject(, "Word.Application")
Set wrdDoc = wrdApp.ActiveDocument
For Each onglet In ThisWorkbook.Sheets
If onglet.Tab.Color = RGB(128, 128, 128) Then
For Each graphique In onglet.ChartObjects
If Left(graphique.Name, 1) = "(" Then 'ws.Tab.Color = RGB(40, 150, 160) Then '("Sheet1") = RGB(40, 150, 160) Then
graphique.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
wrdApp.Selection.Goto what:=wdGoToBookmark, Name:="Graphique2" ' on recherche le signet dans Word pour se positionner
wrdApp.Selection.MoveRight wdCharacter, 1
'wrdApp.Selection.MoveLeft wdCharacter, 1 ' optionnel : pour se placer AVANT le signet (move left)
wrdApp.Selection.PasteSpecial link:=False, DataType:=wdPasteMetafilePicture, Placement:=wdInLine, DisplayAsIcon:=False
End If
Next graphique
End If
Next onglet
' -- Terminer
wrdDoc.Save
Set wrdDoc = Nothing: Set wrdApp = Nothing
Application.ScreenUpdating = True
End Sub |
Partager