Excel ouvrir fichier word pour copier tableau
k
Bonjour, voila plusieurs heures que je cherche une solution à mon problème, et j'espère que vous pourrez m'apporter votre aide
Je cherche à copier des tableaux excel à la suite les uns des autres dans un fichiers word existant, le soucis est que je n'arrive pas à éditer le fichier word existant.
voici mon code :
Sub Export_word()
Dim monFichier As String
Dim WordApp As Object, WordDoc As Object
monFichier = ActiveWorkbook.path & "\" & "PROGRAMME DE TRAVAIL"
On Error Resume Next
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
Set WordDoc = WordApp.Documents.Open("PROGRAMME DE SCIAGE.docx")
With WordApp.Selection
Sheets("LISTE").Range("A1:P45").Copy
.EndKey Unit:=wdStory
.Paste
.TypeParagraph ' saut d'une ligne a la fin du tableau
Sheets("GENERAL").Range("B1:Z160").Copy
.EndKey Unit:=wdStory
.Paste
.TypeParagraph ' saut d'une ligne a la fin du tableau
Sheets("PREPARATION").Range("A2:M46").Copy
.EndKey Unit:=wdStory
.Paste
.TypeParagraph ' saut d'une ligne a la fin du tableau
End With
Application.CutCopyMode = False
WordDoc.SaveAs monFichier
Set WordDoc = Nothing
Set WordApp = Nothing
End Sub