How to add a condition in an includepicture with mergefield

T

tinous

Hi,

I know how to add a varying picture in a mailmerge : {INCLUDEPICTURE
MERGEFORMAT {MERGEFIELD beautifulpicture}} (and after the merge CRT A + PF9
to refresh)

I know how to add a condition to add or not a field using the "If then
else "
{IF {MERGEFIELD num} > 10 {MERGEFIELD aaa} {MERGEFIELD bbb} }

What I want to do, now, is to mix the two and have "beautifulpicture' added
ony if num > 10 .

If I code
{IF {MERGEFIELD num} > 10 {INCLUDEPICTURE MERGEFORMAT {MERGEFIELD
beautifulpicture}} "no picture for this record" } the result is not OK. (the
same picture is added (always the first even after CTR A + PF9)).

Is somebody can help me, please?

Thanks
 
M

macropod

Hi tinous,

Try:
{IF{MERGEFIELD num}> 10 {INCLUDEPICTURE {MERGEFIELD beautifulpicture}}}

Cheers
 
T

tinous

Thanks for your reply.

I've tried, but that doesn't work : nothing appears
my code :
{IF{MERGEFIELD num}> 10 {INCLUDEPICTURE {MERGEFIELD beautifulpicture "no
picture needed is that case" }}}

if num not > 10 : then the texte "no picture needed .." appears
if num > 10 : then .... nothing (no caractere no picture ...)

thanks for your help
 
G

Graham Mayor

No - that doesn't work. During the merge to a new document the picture from
the conditional statement becomes hard wired into the document and cannot be
updated. I can't see a way round this at the moment.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Hi Graham,

Here's a workaround:
{INCLUDEPICTURE {IF{MERGEFIELD Num}> 10 {MERGEFIELD MergePic}
NoMergePic}}
where 'NoMergePic' is the name of a file containing the 'no picture for this
record' string as an image.

For an apparently blank result, you could use a 1-pixel transparent
'NoMergePic'.

Cheers
 
T

tinous

Hi macropos it's WONDERFULL and open a lot of new possibilities. I can manage
to have one picture or an other depending of switch or what ever.

Thanks a lot. Your help is appreciate.
Cheers
 
G

Graham Mayor

Good thinking ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Serafim

Hi Macropod,

For my purposes I changed your instruction just a little and for my surprise
it works much better than I expected {INCLUDEPICTURE {IF{MERGEFIELD photo}=""
"X" {MERGEFIELD photo}.
It's not necessary to merge to printer, nor to merge to a new document and
Ctrl+A and F9. It´s not even necessary to merge, if we simply navigate from
one record to another, the picture is updated. The picture is always updated.
I think it's great.

"macropod" escreveu:
 
A

Anderflash

Serafim, tell me what kind of database you're using to the mail merge,
because with an Access database, I can't update automaticaly the pictures by
navigating from one record to another, I see diferent pictures only if I
merge to a new document or to a printer. But if I use a Word table as a
source for my mail merge, I can.
And another question: If I put pictures inside an Ole object field in a
Access database, I can't throw them to the Word's mail merge, I can throw
only text (in this case, the Word will see a code like 130021230). Is there a
solution?

Thanks

Serafim said:
Hi Macropod,

For my purposes I changed your instruction just a little and for my surprise
it works much better than I expected {INCLUDEPICTURE {IF{MERGEFIELD photo}=""
"X" {MERGEFIELD photo}.
It's not necessary to merge to printer, nor to merge to a new document and
Ctrl+A and F9. It´s not even necessary to merge, if we simply navigate from
one record to another, the picture is updated. The picture is always updated.
I think it's great.

"macropod" escreveu:
 
A

Anderflash

Graham, before I met this newsgroup, I had seen your site and I liked very
much about fields' math. Thanks for the knowledge.

I think your answer is for my second question, about ole object in Access
database to a mail merge.
And to my first question? Do I get the effect of change the photos
automaticaly by navigating between records in a mail merge with an Access
database or I only get the photos updated by merging to a new document?
If this is the normal behavior, the effect would be an interesting feature
to the new office, and also it would be very good if Word recognizes type of
the Access fields, because imagine your mail merge with fields about music,
like a mail merge about music player, you navigate from one record to another
and listen different musics, or different videos, or different charts without
using VBA...
 
G

Graham Mayor

Most word fields do not automatically update - so you have to force an
update. The simplest way to do this is to merge to a new document and force
an update on that document (though merging to the printer directly should
work. This is something I never do because my merges are relatively small,
and I want to ensure the results are correct before I waste expensive ink.)


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peter Jamieson

At one time, INCLUDEPICTURE fields used to update with much less
intervention than they do now (if I remember correctly). Then MS noticed
that malware could theoretically use Word fields to grab data from other
parts of a user's system, insert it into a Word document, and capture it. So
it altered the behaviour of a number of types of fields, and allowed some
control over the behaviour of these fields using the registry key
"FieldCalcSecurityLevel"

There's a description of some of this in the following KB article:

http://support.microsoft.com/kb/330079/en-us

One of the things that it mentions is that the behaviour of the
INCLUDEPICTURE field differs depending on whether or not you included the \d
switch: if you include it, you are much more likely to see your pictures
updating because Word does not store the picture information in the .doc and
so it is less easy for malware to use that method to transmit infomation
about your system.

I say "may" simply because I have never tested all possible combinations of
e.g. Word version, registry settings, and so on, and other settings
generally also come into play. In short - it's one thing to make things work
on one system, with one version of Word, until some new update comes along,
but it's quite another thing to rely on that approach when you're trying to
roll out a reliable solution to end-users (perhaps hundreds or thousands).

So I doubt if the type of database you happen to be using to get your image
file names from is likely to be relevant, but it might be.

As for the whole business of extracting objects from Access databases, I'm
not one of the authors of Word or Access so can only speculate why they
didn't provide facilities to do it, but
a. the chances are that there is insufficient explicit demand from
corporate customers, and MS just decided to stick to supporting merging of
very simple data types.
b. as far as I know, MS has never published the details of how it
represents OLE objects within an MS Access database. It has published KB
articles that tell you how you can, in some cases, extract certain types of
object, but assuming they know the details of how objects are stored within
Jet databases, they keep that information to themselves. In addition, just
because you have an OLE object in an Access database does not mean that you
have an OLE/COM server on your system that is capable of rendering it. If
you don't, it may not even be possible to
 
P

Peter Jamieson

Sorry, I meant to complete my previous message before sending it, but the
main points are that, nice as it would be if we could merge objects - or
even rich text fields - into Word documents,
a. it doesn't look as if MS is going to support that kind of thing "out of
the box" any time soon.
b. the chances are that even if they decide to support such stuff, any such
enhancements would rely on XML standards (although I think there are
considerable technical barriers in the way of achieving stuff like that) and
that it would still be impossible to merge OLE objects.
c. there's no harm in asking - I believe you can still e-mail
(e-mail address removed), but there may be better ways of suggesting
enhancements to Microsoft these days.

Peter Jamieson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top