i have to merge file heder.doc and footer.rtf file content in my template document before start mailmerge fonction.
the logic in word
open file header.doc (only data header in this file)
select all <Crtl+A> and copy <Crtl+C> all data of file
open current model mailmerge
<Crtl+V> paste all data in header section
close
ans same process for footer
i had made this code but sometime there is paragraph is empty and insert cRLF in header modele
have you a better solution ?
tank's
fred
- Code: Select all
HAndF = section.HeadersFooters.Footer 'template
Using foot As New Document()
foot.LoadFromFile(My.Settings.RepSource & Nom2fichier & GLB_const.ext_piedepage, FileFormat.Docx2013)
'remove template header paragraph
For Each p As Paragraph In HAndF.Paragraphs()
HAndF.Paragraphs.Remove(p)
Next
For Each p As Paragraph In foot.Sections(0).Paragraphs
HAndF.Paragraphs.Insert(HAndF.Paragraphs.Count(), p.Clone())
Next
End Using