简体   繁体   中英

How to copy/paste a table in footer word vba

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM