Public Sub genereRapport()
Dim paramRange As Range
Dim StartTime As Single
cursheet = ActiveSheet.Name
Set wordapp = CreateObject("Word.application") 'On definit un objet Word
wordapp.Visible = False
Application.ScreenUpdating = False
Dim wordDoc As Word.Document
Dim tempPath As String
' ouverture du fichier modèle (dans le même répertoire que le livre de bord)
' ce fichier word doit contenir un signet (Insertion/Signet) indiquant l'endroit où copier
tempPath = ActiveWorkbook.Path
sFile = tempPath & "\" & "v_fichier_rapport"
Set wordDoc = wordapp.Documents.Open(sFile, ReadOnly:=True)
copyArray2Bkm "mon_tableau", "mon_signet_word", wordDoc
wordapp.Visible = True
Application.ScreenUpdating = True
Application.Worksheets(cursheet).Activate
End Sub
' copy d'un élément "tableau" (ensemble de cellules) vers un bookmark dans word
' en tant que tableau word
Sub copyArray2Bkm(rangeToCopy As String, bookmark As String, wordDoc As Word.Document)
Set bkmRange = wordDoc.Bookmarks(bookmark).Range
Application.Range(rangeToCopy).Copy
bkmRange.PasteExcelTable False, True, False
wordDoc.Bookmarks.Add bookmark, bkmRange
End Sub