PDA

View Full Version : Solved: Two Headers?



mdmackillop
07-28-2008, 05:57 AM
I've made up code to copy a multi-page letter onto a new document which has a front page header that is the company's headed paper. This works fine. The code also copies and pastes headers and footers for the remainder of the document. The problem is that we use a Continuation Paper with a logo placed top right. If I put this in the template header it gets overwritten by the copy/paste. Any thoughts on the best solution/workaround?


Sub CreatePDFLetter()

Dim aDoc As Range
Dim tDoc As Range
Dim Header As Range
Dim tHead As Range
Dim Footer As Range
Dim tFoot As Range

Set aDoc = ActiveDocument.Range
Set Header = ActiveDocument.Sections(1).Headers(1).Range
Set Footer = ActiveDocument.Sections(1).Footers(1).Range

Set tDoc = Documents.Add(Template:="C:\Templates\PDF Letter.dot", NewTemplate:=False, _
DocumentType:=0).Range
Set tHead = tDoc.Sections(1).Headers(1).Range
Set tFoot = tDoc.Sections(1).Footers(1).Range

aDoc.Copy
tDoc.Paste


Header.Copy
tHead.Paste
Footer.Copy
tFoot.Paste

End Sub