Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Word images - mail merage

Posted on 2008-11-20
4
Medium Priority
?
988 Views
Last Modified: 2016-08-30
Hi,

I have a word document that mail merges various charts onto two pages.  Each of the pages has a pupil name.  I what to create seperate documents for each pupil.  So I want to be able to split merge document into seperate files each containing two pages with the title being the pupil name or set up some sort of macro that will insert the images and then save the document.

I have attached the merge file to show what the layout is.  The merge code I am using is similar to
{INCLUDEPICTURE "c:\\TargetCharts\\{MERGE FIELD PupilID}TC.gif"}

I hope this makes sense.  Thanks,

Desi
Test-Merge.doc
0
Comment
Question by:DesiMck
  • 2
4 Comments
 
LVL 77

Accepted Solution

by:
GrahamSkan earned 400 total points
ID: 23003357
I am unclear about the nub of the problem. Is it about images as the title suggests? You seem to have that covered.

You can produce separate documents in a couple of ways. You can either run a single-record merge or you can split the document afterwards. Provided that you don't have any section breaks in the main document, the latter is fairly simple.

This macro splits the result document at the section breaks and saves each part as a document named from the text at the beginning of the section (up to the first tab).


Sub SplitMergeResult()
    Dim sec As Section
    Dim rng As Range
    Dim strName As String
    Dim DocA As Document
    Dim DocB As Document
   
    Set DocA = ActiveDocument
    For Each sec In DocA.Sections
        Set rng = sec.Range
        rng.MoveEnd wdCharacter, -1 'omit section break
        rng.Copy
        strName = Split(sec.Range.Paragraphs(1).Range.Text, vbTab)(0)
        Set DocB = Documents.Add
        DocB.Range.Paste
        DocB.SaveAs strName & ".doc"
        DocB.Close
    Next sec
End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:DesiMck
ID: 31518650
Thank you for your excellent and speedy reply.  This solution worked.  Sorry for the over complication in my question and the rather misleading title.
0
 

Expert Comment

by:Jamie Gash
ID: 41776101
I need to control the filename of the newly created sperate document. Ideally I'd like to use a mail merge field from within the document (Clients Account Number). Can you explain how I edit line 13 (I assume) to make this work.
0
 
LVL 77

Expert Comment

by:GrahamSkan
ID: 41776341
You would need to locate the text somehow on the document. How you do that depends on the document and your skills,

If any further advice is needed, please raise your own question.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question