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
|
Sub CreerUnInstanceExcelDepuisWord()
Dim I As Integer
Dim MonChemin As String
Dim DocEncours As Document
Dim AppExcel As Object, FicExcel As Object
On Error GoTo Fin
Set DocEncours = ActiveDocument
MonChemin = "C:\Users\...\Xxxxx.xlsm"
Set AppExcel = CreateObject("Excel.Application")
With AppExcel
.Visible = True
Set FicExcel = .Workbooks.Open(MonChemin)
FicExcel.Sheets("Données").ChartObjects("Graphique 2").Copy
With DocEncours
'Cherche le signet nommé Signet1
Selection.GoTo What:=-1, Name:="Signet1"
DoEvents
'Colle le graphe dans le signet
Selection.PasteSpecial , Link:=False
DoEvents
End With
FicExcel.Close savechanges:=False
End With
MsgBox "Import graphe terminé !", vbInformation
GoTo Fin
Fin:
Set FicExcel = Nothing
AppExcel.Quit
Set AppExcel = Nothing
Set DocEncours = Nothing
End Sub |
Partager