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

macropod
07-29-2008, 01:21 AM
Hi mdmackillop,

Try:
Set tHead = tDoc.Sections(1).Headers(1).Range
tHead.Collapse
Set tFoot = tDoc.Sections(1).Footers(1).Range
tFoot.CollapseCheers

mdmackillop
07-29-2008, 04:14 AM
Thanks,
I'll give this a try.

mdmackillop
07-29-2008, 04:28 AM
Works great.
I only had to set the logo fixed in relation to the page, otherwise it moved with the text.

Thanks again
MD