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
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