Google Answers Logo
View Question
 
Q: Microsoft Word Mail Merge Labels ( No Answer,   3 Comments )
Question  
Subject: Microsoft Word Mail Merge Labels
Category: Computers > Software
Asked by: digitalpixman-ga
List Price: $10.00
Posted: 09 Sep 2004 09:54 PDT
Expires: 09 Oct 2004 09:54 PDT
Question ID: 398905
Hi!  This question involves doing a mail merge using Excel and Word. 
My Excel Spreadsheet has a list of Student's Names, Favorite Color,
and Teacher.  I want to print labels sorted by Teacher, with each
teacher's class starting on a new page.  (The only way we have figure
out to do this is by mail merging for each teacher.)  More
specifically, I want Word/Excel to understand that the Field
containing teacher name has changed, and automatically insert a page
break.)  Also, we cannot use MS-Access.  Thanks!
Answer  
There is no answer at this time.

Comments  
Subject: Re: Microsoft Word Mail Merge Labels
From: dreamboat-ga on 09 Sep 2004 21:18 PDT
 
Let's see how comfortable you are with the kludgy version while my
coder writes a better version for you. :)

Create a mail merge main document of labels with the mail merge field
codes in it. Save it keeping it open. (If you've already got a file
like this, please save it to a new name for testing purposes.)

Hit Alt+F11 to open the Visual Basic Editor (VBE).

At left, double-click your file's name and hit Insert-Module from the
menu. Paste the following code into the window that appears at right:

START CODE-----------------

Option Explicit

Sub GetTeachers()

Dim Teachers(1 To 3)    As String
Dim x                   As Long

    Teachers(1) = "'Mrs. Jones'"
    Teachers(2) = "'Mrs. Smith'"
    Teachers(3) = "'Mrs. Ziggywatts'"
    
    For x = 1 To UBound(Teachers)
        ActiveDocument.MailMerge.DataSource.QueryString = _
            "SELECT * FROM C:\Documents and Settings\Anne
Troy\Desktop\data.xls WHERE ((Teacher = " & Teachers(x) & "))" _
             & ""
        With ActiveDocument.MailMerge
            .Destination = wdSendToNewDocument
            .MailAsAttachment = False
            .MailAddressFieldName = ""
            .MailSubject = ""
            .SuppressBlankLines = True
            With .DataSource
                .FirstRecord = wdDefaultFirstRecord
                .LastRecord = wdDefaultLastRecord
            End With
            .Execute Pause:=True
        End With
        ActiveDocument.PrintOut
        ActiveWindow.Close 'False (Use False to not save changes)
    Next x

End Sub

END CODE ----------------------------

Now, edit the code.

Change the 3 in this line to as many teachers as you have:
Dim Teachers(1 To 3)

For each teacher you have, add an additional line like this one,
incrementing the number by one each time and, of course, changing the
teacher's name each time, as you can see in the sample above:
    Teachers(3) = "'Mrs. Ziggywatts'"

When you're done, hit the save diskette on the toolbar to save the
code, then close the VBE.

To test, go to Tools-Macro-Macros and double-click GetTeachers.

This macro will not only mail merge, but print. All you need to do is
close the files when asked if you want to save (which you don't).

I hope to get a better version for you, but can't promise anything.
The better version will get the names from the Excel file for you,
instead of us having to hard-code the names in the VBA code. It will
also not make you close the files. We can also make it so all you have
to do is open that file and it will automatically go print all the
teachers labels and even close itself. If you'd like all that
capability, just say so. We'll get it to you.

Oh...and I'm not a researcher, so it's all free. :)

Nice try, crythias! I didn't know there were any "office geeks" over
here, and it's great to see it. I'm always learning...
Subject: Re: Microsoft Word Mail Merge Labels
From: dreamboat-ga on 16 Sep 2004 22:44 PDT
 
Was this any help for you?
Subject: Re: Microsoft Word Mail Merge Labels
From: digitalpixman-ga on 17 Sep 2004 05:23 PDT
 
Dreamboat:

Thanks so much for you help on this.  In the attend, we decided to use
MS-Access Label Wizard.  The issue was that we have many novice users,
and the Excel directions were far more complicated that Access. 
Thanks so much for you help!

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy