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 ExportWordPaie()
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim NDF As String, NDF2 As String
'créer un document word apartir d'une maquette " bulletin de paie "
NDF = ActiveWorkbook.Path & "\bulletin de paie.docx"
NDF2 = ActiveWorkbook.Path & "\bulletin de paie" & Month(Now()) & "-" & Year(Now()) & ".docx"
On Error Resume Next
Set WordApp = CreateObject("Word.Application")
Set WordDoc = WordApp.Documents.Open(NDF, ReadOnly:=False)
With WordApp
.Visible = True
.Selection.WholeStory
.Selection.Copy
.Selection.Paste
'Nom = ActiveSheet.Range("C" & index).Text
With WordDoc
' insertion du contenu de la cellule C4 dans le tableau "ca marche pas "
Range("C4").Select
Selection.Copy
.Tables(1).Columns(1).Cells(2).Range.Text = Selection.past
End With
End With
WordDoc.Application.ActiveDocument.SaveAs NDF2
WordApp.Application.Quit
End Sub |
Partager