Home > Net >  How to copy/paste a table in footer word vba
How to copy/paste a table in footer word vba

Time:06-08

I have this code :

    Dim word_fichier, word_fichier_sensiblité As Document
    Dim fichier As String
    Dim fichier_sensibilite As String
    Dim word_app As Word.Application

'On récupère le template
    fichier = ActiveWorkbook.Path & "\" & "fsm_template_balises_test.docx"
    fichier_sensibilite = ActiveWorkbook.Path & "\" & "templates_sensibilité.docx"
    
'Ouverture de word
    Set word_app = CreateObject("Word.Application")
    With word_app
        .Visible = True
        .WindowState = 1
    End With
    
'Définition de l'objet fichier word
    Set word_fichier = word_app.Documents.Open(fichier)
    Set word_fichier_sensiblité = word_app.Documents.Open(fichier_sensibilite)

'Copie du tableau
    word_fichier_sensiblité.Tables(1).Range.Copy

    
'Collage du tableau
    With word_fichier.Sections(1).Footers(wdHeaderFooterPrimary)
        .Range.Paste
    End With

I have an existing footer in my word_fichier and i want to paste a table from the word_fichier_sensiblité. For now my table is erasing my existing footer, idk how to paste this table at the beginning of my footer. Any advise ?

Thanks

CodePudding user response:

With word_fichier.Sections(1).Footers(wdHeaderFooterPrimary).Range
    .Collapse wdCollapseStart
    .Paste
End With
  • Related