#  Other Applications & Softwares  > Word Formatting & General >  >  Mail Merge Image check for existence and display text if not exist

## lennym2014

Am trying to check if an image exists in mail merge, if it does display it, if not display some text.
This is the code that i am using.

{IF {INCLUDEPICTURE {IF TRUE { MERGEFIELD Logo}}\d} {INCLUDEPICTURE {IF TRUE { MERGEFIELD Logo}}\d} {MERGEFIELD CompanyName}}

Please help, have been struggling with this for several days now. What is missing in this code i dont seem to get the correct results. if the image is not there all it shows me is that there was supposed to be an image with a red x at the top left corner.

----------


## macropod

You can't test for the existence of a file via mailmerge and conditionally output an image or text. What you would need to use is a field in the data source that indicates whether the image exists.

----------


## lennym2014

Thanks. i understand that and that is what i am trying to do. The IF TRUE statement does it not do that for me, check if the file exists or not?
In the example that i have shown there "Logo" is a file name with a full path of where this image is located. Is there anything wrong with the 
code in my example?

----------


## macropod

But that is not what your field code is trying to do. Assuming the 'Logo' field is empty when there is no image, you need something like:
{IF{MERGEFIELD Logo}= "" {MERGEFIELD CompanyName} {MERGEFIELD Logo}}

----------


## lennym2014

Thanks will try that. I used the IF TRUE statement so that i do not have to refresh to get the correct image, as i have read from other posts. But let me try it this way and see if it will work.

----------


## lennym2014

Have tried it and the result is perfect if the image exists but if it does not instead of showing me just the name it shows an outline of an image with a red x at the top left corner  and this is the code i used:

 {IF {INCLUDEPICTURE {MERGEFIELD Logo}} = "" {MERGEFIELD CompanyName} {INCLUDEPICTURE {MERGEFIELD Logo}\d}}

what am i doing wrong ?

TestImage2.png

----------


## macropod

For starters, your field code is quite different from what I suggested...

----------


## lennym2014

if i dont use includepicture, it just shows me the path of where the logo is located. that is if i use {MERGEFIELD Logo} instead of showing me the logo it shows me "c:\\EPS\\Logos\\Logo0006.png".

----------


## macropod

Sorry, the field code should have been:
{IF{MERGEFIELD Logo}= "" {MERGEFIELD CompanyName} {INCLUDEPICTURE {MERGEFIELD Logo}\d}}

----------


## lennym2014

thanks. In my case i think i will not have a situation where that field is empty but i might have a situation where i do not have that particular logo in the folder. what code do i use in that situation?

----------


## macropod

As I said before, you will need a _field_ you can test to tell you whether there is a logo - you cannot test for the logo's presence on disc.

----------

