Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Shetland Isles, Shetland, Scotland
    Posts
    154
    Thanks
    3
    Thanked 1 Time in 1 Post

    Printing sample of mailmerge (2000 SP3)

    Hi,

    I have a mailmerge that has 15 or so types of letter in it (it's driven from 15 Access queries through a Union query).

    I'd like word to print one of each type of letter as a sample output.

    I have a field that's unique to each type of letter CLM01, CLM02, CLM03 etc. is there a way that I can tell word to print only one letter from each type?

    Thanks,
    Jim MacLeod
    Shetland Isles

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing sample of mailmerge (2000 SP3)

    I think you'll have to create a query in Access that returns one record of each type, and use that as data source for ther sample mail merge.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Shetland Isles, Shetland, Scotland
    Posts
    154
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Printing sample of mailmerge (2000 SP3)

    I've tried that and it works, but it's very inconvenient for what I'm doing.

    My "english" verion of what I'd like word to do is as follows:

    dim lettertype as text

    For letternumber=firstrecord to lastrecord

    mailmerge recordnumber letter

    if lettertype <> lastlettertype then print letter

    endif

    lastlettertype=lettertype

    next letternumber

    What I'm trying to do is mailmerge each record in turn & when the lettertypr field changes, print the letter.

    I'm not asking anyone to write the macro, if I could just know what the VB commands are.

    Thanks
    Jim

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing sample of mailmerge (2000 SP3)

    Perhaps you can adapt the following macro to suit your purposes:

    Sub PrintSample()
    ' Substitute correct field name
    Const strField = "CategoryID"
    Dim strPrev As String
    Dim intCount As Integer

    With ActiveDocument.MailMerge
    .ViewMailMergeFieldCodes = False
    With .DataSource
    .ActiveRecord = wdLastRecord
    intCount = .ActiveRecord
    .ActiveRecord = wdFirstRecord
    Do
    If Not .DataFields(strField).Value = strPrev Then
    ActiveDocument.PrintOut
    End If
    strPrev = .DataFields(strField).Value
    .ActiveRecord = wdNextRecord
    Loop Until .ActiveRecord = intCount
    If Not .DataFields(strField).Value = strPrev Then
    ActiveDocument.PrintOut
    End If
    End With
    End With
    End Sub

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Shetland Isles, Shetland, Scotland
    Posts
    154
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Printing sample of mailmerge (2000 SP3)

    Thank you!

    Looks like that's EXACTLY the type of thing I need. Now to try to understand it........... :-)

    Jim

  6. #6
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Shetland Isles, Shetland, Scotland
    Posts
    154
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Printing sample of mailmerge (2000 SP3)

    Yes it works!

    A couple of things:

    Firstly for relative newbies like myself incase they make the same mistake: To get the code into Word I decided to cut & paste it into an outlook e-mail & send it to myself ( I won't bore you with why that was sensible at the time). I then cut & pasted it from Outlook to the VB window in word. I got a lot of red in the code, with hindsight I should have realised that someting more than a typo had occured, but I didn't. I merrily scoured the code & the relevant help files to see if I could spot the missing/extra dot or space, no luck.

    Eventually I worked out that some invisible characters had got into the code. I cut & pasted the code into the word document and voila.. loads of small circles where I thought there were spaces. I removed the invisible characters, repasted and it all worked. An hour or so wasted but a valuable lesson learnt!

    Second point: This code works fine but is very very slow, word seems to cycle through the mailmerge a huge number of times. I suspect that when the code asks for record number 500, word merges from 1-500. Just like when you type in 500 in the record box on the mailmerge toolbar, rather than retrieving the next record, like when you hit the next record button.

    Is there a command to mimic the "next record" button or is it just the way it is?? I can live with the current speed (20 min to print 7 samples from 800 letters so far) but it would obviously be nice if it could go quicker.

    Thanks again,
    jim

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing sample of mailmerge (2000 SP3)

    The line .ActiveRecord = wdNextRecord is the equivalent of pressing the Next button, but this becomes very inefficient in a large dataset.

    I don't know a way around this without either changing the source query (which you rejected) or changing the merge document (which is probably not acceptable either because you'd have to change it back to perform the full mail merge).

Posting Permissions

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