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
| 'cochez la référence Microsoft Word 12.0 Object Library
Private Sub CommandButton1_Click()
Dim oWord As Word.Application
'Créer une instance de word
Set oWord = CreateObject("Word.Application")
'Copier une plage depuis Excel
Range("B6:D21").Select
Selection.Copy
'Ouvrir un nouveau document
oWord.Documents.Open "D:\Document1.docx"
'rendre le document word visible
oWord.Visible = True
'cherche le signet dans la feuille word
oWord.Selection.GoTo What:=wdGoToBookmark, Name:="Signet1"
'Coller la plage dans Word
oWord.Selection.PasteAndFormat (wdPasteDefault)
'aligne le tableau au milieu de la page
oWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Range("E6:G21").Select
Selection.Copy
oWord.Selection.GoTo What:=wdGoToBookmark, Name:="Signet2"
oWord.Selection.PasteAndFormat (wdPasteDefault)
oWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Range("H6:J21").Select
Selection.Copy
oWord.Selection.GoTo What:=wdGoToBookmark, Name:="Signet3"
oWord.Selection.PasteAndFormat (wdPasteDefault)
oWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
'Annuler le mode couper/copier
Application.CutCopyMode = False
End Sub |