Results 1 to 3 of 3

Thread: MailMerge

  1. #1
    Guest

    Exclamation

    Hello,

    I have a tiny problem.

    I'm merging clientadresses from a database into word.

    There's no problem until Word-document becomes Visible.
    Only the last field is visible.
    I need to insert a pagebreak or a space between the fields, but i don't know how to do that.
    Can anyone help me?

    I have inserted the code so it is a litlle bit more clear.

    Dim myWrd As Word.Document
    Dim myMerge As Word.MailMerge
    Dim AppWord As Word.Application


    Set AppWord = New Word.Application
    Set myWrd = AppWord.Documents.Add
    Set myMerge = myWrd.MailMerge
    With myMerge
    .Application.Visible = True
    .OpenDataSource Name:=Replace(Get_ReportAdres, "Project BH\CrystalReports", "Databases\Boekhouden.mdb"), Connection:=gConn, SQLStatement:="SELECT Naam, Straat, PostCode, Gemeente FROM AfdLijsten"
    .Fields.Add Range:=myWrd.Range, Name:="Naam"
    'space or break?
    .Fields.Add Range:=myWrd.Range, Name:="Straat"
    'space or break?
    .Fields.Add Range:=myWrd.Range, Name:="PostCode"
    'space or break?
    .Fields.Add Range:=myWrd.Range, Name:="Gemeente"
    'space or break?
    .Execute
    myWrd.Close wdDoNotSaveChanges
    End With



  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    I've been looking at MSWord 97 here, so this may differ a little bit. First, you might need to have this line added to enable pagebreaks:

    ActiveDocument.Tables(2).AllowPageBreaks = True

    Code is :
    Code:
    Selection.InsertBreak Type:=wdPageBreak
    I see what you mean, in the help files or internet there is nothing on this, I always find it helpful to cheat slightly...
    • [1] Goto tools menu, create a new macro
      [2] Manually run the procedure - i.e. in this case, insert, pagebreak option
      [3] Start the visual basic editor (press alt+F11)
      [4] Look up the code created under the normal project and modules folder


    Hope this helps you! If you need this for word 97 if the above doesn't work, I can look at home for you, just post here again.

    [Edited by alex_read on 11-20-2000 at 05:51 AM]

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Guest
    Thank you very much alex_read.

    The problem isn't solved yet. I'm working with Word 2000 and I'm still trying to figger the mailmerge out.
    But the tip about the macro's is fantastic.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width