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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
Private Sub CopieDansWord_Click()
Dim appword As New Word.Application
Dim docword As New Word.document
Dim rng As Range
'Ajoute un nouveau document
With appword
.Visible = True
Set docword = .Documents.Add
.Activate
'Mise en page paysage
docword.PageSetup.Orientation = wdOrientLandscape
End With
'Ajoute une ligne de titre et la met en forme
With appword.Selection
.TypeText Text:=""
.HomeKey Unit:=wdLine
.EndKey Unit:=wdLine, Extend:=wdExtend
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Size = 1
With .Font
.Name = "Arial"
.Bold = False
.Italic = False
.smallcaps = False
End With
'Copie le tableau excel "reception" dans le presse-papiers
Range("B2:N4").Copy
'Colle le tableau dans Word avec liaison
.EndKey Unit:=wdLine
.TypeParagraph
.TypeParagraph
.PasteSpecial link:=True, DataType:=wdpastOLEObject, Placement:=wdInLine, DisplayAsIcon:=False
'###########################################################
'Copie le tableau excel "reception" dans le presse-papiers
Range("B11:N22").Copy
'Colle le tableau dans Word avec liaison
.EndKey Unit:=wdLine
.TypeParagraph
.TypeParagraph
.PasteSpecial link:=True, DataType:=wdpastOLEObject, Placement:=wdInLine, DisplayAsIcon:=False
'Copie le graphique "reception" dans le presse-papiers
Worksheets("TB Activité").ChartObjects(1).Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
'Colle le graphique dans Word avec liaison
.TypeParagraph
.TypeParagraph
.PasteAndFormat (wdchartlinked)
'#########################################################
'Copie le tableau excel "stockage" dans le presse-papiers
Range("B23:N34").Copy
'Colle le tableau dans Word avec liaison
.EndKey Unit:=wdLine
.TypeParagraph
.TypeParagraph
.PasteSpecial link:=True, DataType:=wdpastOLEObject, Placement:=wdInLine, DisplayAsIcon:=False
'Copie le graphique "stockage" dans le presse-papiers
Worksheets("TB Activité").ChartObjects(2).Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
'Colle le graphique dans Word avec liaison
.TypeParagraph
.TypeParagraph
.PasteAndFormat (wdchartlinked)
'#############################################################
'Copie le tableau excel "préparation" dans le presse-papiers
Range("B35:N46").Copy
'Colle le tableau dans Word avec liaison
.EndKey Unit:=wdLine
.TypeParagraph
.TypeParagraph
.PasteSpecial link:=True, DataType:=wdpastOLEObject, Placement:=wdInLine, DisplayAsIcon:=False
'Copie le graphique "préparation" dans le presse-papiers
Worksheets("TB Activité").ChartObjects(3).Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
'Colle le graphique dans Word avec liaison
.TypeParagraph
.TypeParagraph
.PasteAndFormat (wdchartlinked)
'#############################################################
'Copie le tableau excel "expédition" dans le presse-papiers
Range("B47:N58").Copy
'Colle le tableau dans Word avec liaison
.EndKey Unit:=wdLine
.TypeParagraph
.TypeParagraph
.PasteSpecial link:=True, DataType:=wdpastOLEObject, Placement:=wdInLine, DisplayAsIcon:=False
'Copie le graphique "expédition" dans le presse-papiers
Worksheets("TB Activité").ChartObjects(4).Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
'Colle le graphique dans Word avec liaison
.TypeParagraph
.TypeParagraph
.PasteAndFormat (wdchartlinked)
'#############################################################
End With
With docword
'Enregistre le document Word dans le même dossier que le classeur excel
.SaveAs ThisWorkbook.Path & "\TB Activité.doc", Allowsubstitutions:=True
'Aperçu du résultat dans Word
.PrintPreview
End With
'Réinitialise l'objet
Set appword = Nothing
End Sub |
Partager