PDA

View Full Version : Solved: Images in Mail Merge



FranChasing
01-20-2013, 10:26 AM
Hi,

I live in Brazil and I come to ask for help illustrious foreigners.
I wonder if Microsoft Word automatically inserts IMAGES in Mail Merge.
If possible, what procedure?

Sorry, I'm using Google Translator

Very grateful !!!
:help

FranChasing
01-27-2013, 10:00 PM
Hi,

I live in Brazil and I come to ask for help illustrious foreigners.
I wonder if Microsoft Word automatically inserts IMAGES in Mail Merge.
If possible, what procedure?

Sorry, I'm using Google Translator

Very grateful !!!
:help

People, please help me!!

Give me any tip that can make a DIRECT MAIL with pictures?
Below this VBA routine inserts a folder of images into a page and would like to file after completing individualized it position itself within each image of each page of Word mail merge.

Let's all help!!

'-- vba --

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oFD As FileDialog
Dim vSelectedItem As Variant
Dim oShp As Word.Shape
Dim i As Long
Set oFD = Application.FileDialog(msoFileDialogFilePicker)
i = 0
With oFD
If .Show = -1 Then
For Each vSelectedItem In .SelectedItems
Set oShp = ActiveDocument.Shapes.AddPicture(FileName:=vSelectedItem, _
LinkToFile:=False, _
SaveWithDocument:=True, _
Left:=305 + i, _
Top:=1.9 + i, _
Width:=80, _
Height:=100, _
Anchor:=Selection.Range)
i = i + 0
Next vSelectedItem
End If
End With
Set oFD = Nothing
End Sub

:help
Thank you

macropod
01-29-2013, 01:15 AM
Hi FranChasing,

Greg's code is not for a mailmerge.

When embedding a mailmerge field in an INCLUDEPICTURE field for the purpose of merging graphics:
1. the filepaths to the fields need to have the separators expressed as '\\' or '/' instead of the usual '\';
2. the pictures usually won't show until you refresh the fields (eg Ctrl-A, then F9); and
3. even after updating the images, they remain linked to the image files, which can be an issue if you later delete the image or you need to send the merged output to someone else.

The following field construction addresses all three issues (i.e. you don't need to do anything special to the paths, or refresh the fields, and they'll no longer be linked to the source files):

{IF {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\«Image»"} \d} {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\«Image»"} \d}}
or

{IF {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\{MERGEFIELD Image}"} \d} {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\{MERGEFIELD Image}"} \d}}
After running a mailmerge coded this way, you'll have the correct, unlinked image for each record. This form of field construction can be very useful where the filepath for the images is held in the mailmerge data source, in which case you could use:

{IF {INCLUDEPICTURE {IF TRUE "«FilePath»\«Image»"} \d} {INCLUDEPICTURE {IF TRUE "«FilePath»\«Image»"} \d}}
or

{IF {INCLUDEPICTURE {IF TRUE "{MERGEFIELD FilePath}\{MERGEFIELD Image}"} \d} {INCLUDEPICTURE {IF TRUE "{MERGEFIELD FilePath}\{MERGEFIELD Image}"} \d}}
Note 1: You need a path separator between the filepath mergefield and the image mergefield. If that separator is included in the source data, it can be omitted from the field above construction but leaving it there has no adverse effects either.

If the path data are included with in the image field, you can use:

{IF {INCLUDEPICTURE {IF TRUE «Image»} \d} {INCLUDEPICTURE {IF TRUE «Image»} \d}}
or

{IF {INCLUDEPICTURE {IF TRUE {MERGEFIELD Image}} \d} {INCLUDEPICTURE {IF TRUE {MERGEFIELD Image}} \d}}
For what it's worth, *provided* the path has the separators expressed as '\\' or '/', you can retain the links by omitting the all-encompassing IF test and the images will display correctly without the need to refresh the fields after completing the merge. For example:

{INCLUDEPICTURE {IF TRUE "C:\\Users\\My Document Path\\Pictures\\«Image»"} \d}
Note 2: The field brace pairs (ie '{ }') for the above examples are created in the body of the document via Ctrl-F9 (Cmd-F9 on a Mac) - you can't simply type them or copy & paste them from this post. Likewise, you can't type or copy & paste the chevrons (ie '« »') - they're part of the actual mergefields, which you can insert from the mailmerge toolbar.

Note 3: You will have to change the file paths and mergefield names shown in the examples to suit your mailmerge requirements.

FranChasing
01-29-2013, 07:35 PM
Hi FranChasing,

Greg's code is not for a mailmerge.

When embedding a mailmerge field in an INCLUDEPICTURE field for the purpose of merging graphics:
1. the filepaths to the fields need to have the separators expressed as '\\' or '/' instead of the usual '\';
2. the pictures usually won't show until you refresh the fields (eg Ctrl-A, then F9); and
3. even after updating the images, they remain linked to the image files, which can be an issue if you later delete the image or you need to send the merged output to someone else.

The following field construction addresses all three issues (i.e. you don't need to do anything special to the paths, or refresh the fields, and they'll no longer be linked to the source files):

{IF {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\«Image»"} \d} {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\«Image»"} \d}}
or

{IF {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\{MERGEFIELD Image}"} \d} {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\{MERGEFIELD Image}"} \d}}
After running a mailmerge coded this way, you'll have the correct, unlinked image for each record. This form of field construction can be very useful where the filepath for the images is held in the mailmerge data source, in which case you could use:

{IF {INCLUDEPICTURE {IF TRUE "«FilePath»\«Image»"} \d} {INCLUDEPICTURE {IF TRUE "«FilePath»\«Image»"} \d}}
or

{IF {INCLUDEPICTURE {IF TRUE "{MERGEFIELD FilePath}\{MERGEFIELD Image}"} \d} {INCLUDEPICTURE {IF TRUE "{MERGEFIELD FilePath}\{MERGEFIELD Image}"} \d}}
Note 1: You need a path separator between the filepath mergefield and the image mergefield. If that separator is included in the source data, it can be omitted from the field above construction but leaving it there has no adverse effects either.

If the path data are included with in the image field, you can use:

{IF {INCLUDEPICTURE {IF TRUE «Image»} \d} {INCLUDEPICTURE {IF TRUE «Image»} \d}}
or

{IF {INCLUDEPICTURE {IF TRUE {MERGEFIELD Image}} \d} {INCLUDEPICTURE {IF TRUE {MERGEFIELD Image}} \d}}
For what it's worth, *provided* the path has the separators expressed as '\\' or '/', you can retain the links by omitting the all-encompassing IF test and the images will display correctly without the need to refresh the fields after completing the merge. For example:

{INCLUDEPICTURE {IF TRUE "C:\\Users\\My Document Path\\Pictures\\«Image»"} \d}
Note 2: The field brace pairs (ie '{ }') for the above examples are created in the body of the document via Ctrl-F9 (Cmd-F9 on a Mac) - you can't simply type them or copy & paste them from this post. Likewise, you can't type or copy & paste the chevrons (ie '« »') - they're part of the actual mergefields, which you can insert from the mailmerge toolbar.

Note 3: You will have to change the file paths and mergefield names shown in the examples to suit your mailmerge requirements.

Hello, Macropod

Sorry, but unfortunately I'm not able to include images using these commands you are indicating ...
I can do manually but using INCLUDEPICTURE

{INCLUDEPICTURE "c:\\einstein\\000204.jpg" \d}

Please, if possible, send me a file. DOC or. DOCX that works 100%.

e-mail: franchasing@hotmail.com

Thank you.

macropod
01-29-2013, 09:41 PM
Sorry, but unfortunately I'm not able to include images using these commands you are indicating ...
Why not? The field codes work fine for other users. This is a well-documented approach, developed by me and used by many people.

FranChasing
01-30-2013, 06:38 AM
Hi, Macropod

Please could send a small example. Doc or docx?
These commands are true, I know, the problem is that I am not able to use them ... I put the command and nothing happens!
Note that I am using this simple, but it's manual ...

e-mail: franchasing@hotmail.com

Thank you.

macropod
01-30-2013, 01:59 PM
Since I don't know your field name or what it contains, there'd be little point in doing that. As for 'nothing happens', did you execute the merge?

FranChasing
01-30-2013, 02:34 PM
Since I don't know your field name or what it contains, there'd be little point in doing that. As for 'nothing happens', did you execute the merge?

Macropod,
I'm just asking you a small example .DOC to see how you are using the code INCLUDEPICTURE.
You can create your event, with their fields, images, etc. ...
For example, I'm using this command like this:

IF {INCLUDEPICTURE {IF TRUE "C:\einstein\«Image»"} \d} {INCLUDEPICTURE {IF TRUE "C:\einstein\«Image»"} \d}

There is duplicated?
So what is «Image»? It is a field? I do not understand ...

macropod
01-30-2013, 08:54 PM
So what is «Image»? It is a field? I do not understand ...
«Image» is what you'd see if you insert a mergefield named 'Image' into your document. When you have Word's field code display toggled 'on', you will see {MERGEFIELD Image} instead. See Note 2 in my initial response. Obviously, if the field name in your data source isn't 'Image' you'd have to change either that or the field code to suit.

Attached is a document with the field. The document isn't a mailmerge document, so the field won't do anything useful and you shouldn't expect to see the correct images in a mailmerge document until the mailmerge is executed.

FranChasing
01-31-2013, 04:40 PM
Hi, Macropod

I give up!! I can not ...
When I update F9, appears a frame with broken link.
Sorry!

Thank you.

macropod
01-31-2013, 08:46 PM
It seems to me that you are not paying attention. As I've already said:

the field won't do anything useful and you shouldn't expect to see the correct images in a mailmerge document until the mailmerge is executed.
If your path and field names are correct, the pictures will be inserted when the mailmerge is executed and not before - including not for a preview.

FranChasing
01-31-2013, 09:26 PM
Hi, Macropod

Understand, I've done and tried all forms:
creating direct mail or trying to insert straight.
Anyway, I do not know how. Never seen such an example with Mail Merge Images via INCLUDEPICTURE.
Using OnMerge Images (http://onmerge.com/) managed to mount perfectly Merge with images from the database. DAT, the problem is that failed and MERGE FILES INDIVIDUAL FINISH. Generated only the first two pages.
In contact with JohnD, support OnMerge Images he reported that my database format .DAT is very extensive, and there are many columns in a bug that prevents Word to generate the individual files by OnMerge Images.
Unfortunately you can not run 100%.
Please visit this link and download the file:
.DOC and .DAT, the 51 compressed images.
Create a folder in C:\Einstein and save all files.
Open the file. DOC and see all pictures in the Mail Merge made ​​by OnMerge Images. Try to Finish Merge ...
Then you are free to test using the commands INCLUDEPICTURE by inserting merge fields Aluno_Codigo.

macropod
01-31-2013, 10:16 PM
Hi FranChasing,

The field code I gave you is not intended for use with products like OnMerge Images™. Such products have their own ways of doing things and are often incompatible with anything anyone else produces (even if that's only standard field codes such as I have used).

I have had a look at both your mailmerge document and the dat file. I can't see any evidence of the field code I've provided in the mailmerge document; nor can I see any field with a reference to the image names with a .jpg extension in the dat file. You can't expect to get the right results with the wrong setup.

From what I can see, it should work if you change the field code from:

{IF {INCLUDEPICTURE {IF TRUE "C:\Einstein\{MERGEFIELD Image}"} \d} {INCLUDEPICTURE {IF TRUE "C:\Einstein\{MERGEFIELD Image}"} \d}}
to:

{IF {INCLUDEPICTURE {IF TRUE "C:\Einstein\{MERGEFIELD Aluno_Codigo}.jpg"} \d} {INCLUDEPICTURE {IF TRUE "C:\Einstein\{MERGEFIELD Aluno_Codigo}.jpg"} \d}}
and use that field code in place of:
{ HYPERLINK \l " " \o "OnMerge Image" }

FranChasing
01-31-2013, 11:00 PM
Hello, Macropod

PERFECT !!!


{IF {INCLUDEPICTURE {IF TRUE "C:\Einstein\{MERGEFIELD Aluno_Codigo}.jpg"} \d} {INCLUDEPICTURE {IF TRUE "C:\Einstein\{MERGEFIELD Aluno_Codigo}.jpg"} \d}}

Now the command is working 100%
Was missing only .JPG after Aluno_Codigo field.
Impressive as MICROSOFT WORD is FANTASTIC and MACROPOD man is a GENIUS !!!

THANK YOU.