Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / December 2003

Tip: Looking for answers? Try searching our database.

Add text at top of Document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matthew - 29 Dec 2003 00:32 GMT
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
Graham Mayor - 29 Dec 2003 06:20 GMT
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

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
    Graham Mayor -  Word MVP
      E-mail gmayor@mvps.org
     Web site www.gmayor.com
 Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>

> Hi all,
>
[quoted text clipped - 37 lines]
>         .Execute
> End With
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.