Add text at top of Document

M

Matthew

Hi all,

I am doing a Mail Merge with VBA, and wanted to print a bit of text at the
top of every page.

I put the text in the header before merging, but that "pushed" the label
table down, so the last row of labels was on the next page. This happened
on every page.

I tried moving the header up higher (with headers().range) and adding the
text, but it didn't save the header position in the merged document.

Any suggestions?

Matthew

Relevant code:

Dim oApp As Word.Application
Dim oDoc As Word.Document

'Start a new document in Word
Set oApp = CreateObject("Word.Application")
Set oDoc = oApp.Documents.Add

'Enter header info
oDoc.Sections(1).PageSetup.HeaderDistance = InchesToPoints(0.25)
oDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range = Left(folder,
Len(folder) - 1)

'Snip merge fields setup and data source setup
With oDoc.MailMerge
oApp.MailingLabel.CreateNewDocument Name:="5160", Address:="", _
AutoText:="MyLabelLayout", LaserTray:=wdPrinterManualFeed

'Execute the mail merge to generate the labels.
.Destination = wdSendToNewDocument
.Execute
End With
 
G

Graham Mayor

If you use a header and use the standard label layouts it will screw up your
document. The only solutions are to create your own custom label layout
which allows for the presence of the header or you might consider placing an
autotext entry containing your text in a borderless text box set behind the
text in the main page area. For this you would have to arrange for the
autotext to be placed on each page during the merge, using a conditional
field and a count

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top