Sub CréerRapport()
Application.ScreenUpdating = False
Pat = ActiveWorkbook.Name
Dim appWrd As Word.Application
Dim docWrd As Word.Document
Set appWrd = New Word.Application
appWrd.Visible = False
Set docWrd = appWrd.Documents.Add
With docWrd
.PageSetup.LeftMargin = CentimetersToPoints(1)
.PageSetup.TopMargin = CentimetersToPoints(1)
.PageSetup.BottomMargin = CentimetersToPoints(1)
.PageSetup.RightMargin = CentimetersToPoints(1)
End With
Windows(Pat).Activate
Range("B2:AE51").Select
Selection.Copy
With appWrd.Selection
.Paste
.InsertBreak Type:=wdSectionBreakNextPage
End With
Windows(Pat).Activate
Range("B53:AE107").Select
Selection.Copy
With appWrd.Selection
.Paste
.InsertBreak Type:=wdSectionBreakNextPage
End With
Range("B109:AE160").Select
Selection.Copy
Range("L13").Select
With appWrd.Selection
.Paste
End With
Application.CutCopyMode = False
docWrd.SaveAs Filename:="Rapport_de_" & ActiveCell.Text & ".doc", FileFormat:=wdFormatDocument
Set docWrd = Nothing
appWrd.Quit
Set appWrd = Nothing
Windows(Pat).Activate
Range("AH9").Select
Application.ScreenUpdating = True
MsgBox " Ce rapport a bien été enregistré ! "
End Sub