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
| Sub RapportRD()
Dim appWord As New Word.Application
Dim docWord As New Word.Document
Dim Fichier As String
Dim DerLigne As Long
On Error Resume Next
Fichier = "R:\RECHERCHE-ET-MODELES\0.MAJ\test.docx"
'Appeler le document word existant
Set appWord = CreateObject("Word.Application")
appWord.Visible = True
Set docWord = appWord.Documents.Open(Fichier)
'Alignement centré
appWord.Selection.HomeKey unit:=wdLine
appWord.Selection.EndKey unit:=wdLine, Extend:=wdExtend
appWord.Selection.ParagraphFormat.Alignment = wdalignparagraphcenter
'Copier le tableau que l'on veut insérer
Feuil3.Range("J11:O14").Copy
appWord.Selection.EndKey unit:=wdLine
'Coller le tableau dans la première page
appWord.Selection.PasteSpecial link:=True, DataType:=wdPasteOLEObject, Placement:=wdLine, DisplayAsIcon:=False
'Le placer dans la feuille
docWord.Tables(1).AutoFitBehavior wdAutoFitWindow
Application.CutCopyMode = False
docWord.Shapes(1).Top = 220
docWord.Shapes(1).Left = -135
docWord.Shapes(1).ZOrder msoSendBehindText
End Sub |
Partager