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
| 'Référence Microsoft Word 14.0 Object Library chargée dans menu déroulant Outils
'VBA 7.0
'Office 2010
'Excel et Word v.14
Option Explicit
'macro édition Rapport
Sub rapport()
'Lancement application Word et Ouverture du document-modèle (format .docm) rendu visible
Dim aWord As Word.Application
Dim dWord As Word.Document
Set aWord = CreateObject("Word.Application")
aWord.Visible = True
'chemin EXACT du fichier !!!
Set dWord = aWord.Documents.Open("MON PRé-RAPPORT.docm")
'chapitre I : SYNTHESE
'Copie Tableau 1 depuis Excel onglet "synth global diag+RenfcT"
Sheets("synth global diag+RenfcT").Select
Range("H12:R21").Select
Selection.Copy
'Cherche Signet1 dans le rapport-modèle
aWord.Selection.Goto What:=wdGoToBookmark, Name:="Signet1"
DoEvents
'Colle Tableau 1 à Signet1
aWord.Selection.PasteSpecial , Link:=False, DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
'autres collages possibles
'aWord.Selection.PasteSpecial , Link:=False, DataType:=wdPasteEnhancedMetafile, DisplayAsIcon:=False
'aWord.Selection.PasteAndFormat (wdPasteDefault) 'copie en format tableau / ajuste à la largeur de la page word POURRIE
'mise en page du Tableau 1 selon sa taille
aWord.Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
DoEvents
With dWord.InlineShapes(1)
.LockAspectRatio = msoTrue
.Height = 140 'redimensionne hauteur image
'.Width = 510 'redimensionne largeur image
.ConvertToShape
End With
dWord.Shapes(1).Left = wdShapeCenter
dWord.Shapes(1).Rotation = 90
ActiveDocument.Shapes(1).ConvertToInlineShape |
Partager