+ Reply to Thread
Results 1 to 11 of 11

Mail Merge Image check for existence and display text if not exist

  1. #1
    Registered User
    Join Date
    01-05-2015
    Location
    Centurion, South Africa
    MS-Off Ver
    2007
    Posts
    6

    Mail Merge Image check for existence and display text if not exist

    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.

  2. #2
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,667

    Re: Mail Merge Image check for existence and display text if not exist

    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.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    01-05-2015
    Location
    Centurion, South Africa
    MS-Off Ver
    2007
    Posts
    6

    Re: Mail Merge Image check for existence and display text if not exist

    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?

  4. #4
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,667

    Re: Mail Merge Image check for existence and display text if not exist

    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}}

  5. #5
    Registered User
    Join Date
    01-05-2015
    Location
    Centurion, South Africa
    MS-Off Ver
    2007
    Posts
    6

    Re: Mail Merge Image check for existence and display text if not exist

    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.

  6. #6
    Registered User
    Join Date
    01-05-2015
    Location
    Centurion, South Africa
    MS-Off Ver
    2007
    Posts
    6

    Re: Mail Merge Image check for existence and display text if not exist

    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
    Last edited by lennym2014; 01-08-2015 at 02:47 AM. Reason: Image with red x

  7. #7
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,667

    Re: Mail Merge Image check for existence and display text if not exist

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

  8. #8
    Registered User
    Join Date
    01-05-2015
    Location
    Centurion, South Africa
    MS-Off Ver
    2007
    Posts
    6

    Re: Mail Merge Image check for existence and display text if not exist

    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".

  9. #9
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,667

    Re: Mail Merge Image check for existence and display text if not exist

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

  10. #10
    Registered User
    Join Date
    01-05-2015
    Location
    Centurion, South Africa
    MS-Off Ver
    2007
    Posts
    6

    Re: Mail Merge Image check for existence and display text if not exist

    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?

  11. #11
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,667

    Re: Mail Merge Image check for existence and display text if not exist

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Running Word Mail Merge from Excel 2010 - Mail Merge workbook fails
    By pl05.lau@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-05-2015, 07:35 AM
  2. Barcode image in Excel and MS Word Mail merge
    By eyeman96 in forum Excel General
    Replies: 4
    Last Post: 01-19-2014, 09:52 PM
  3. Mail merge based on check boxes
    By dans123 in forum Access Tables & Databases
    Replies: 1
    Last Post: 09-17-2012, 08:58 AM
  4. Check if file exist contains certain text/value
    By DB4284 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-17-2010, 04:46 AM
  5. [SOLVED] display image when specific value in a cell exist
    By nicosalt in forum Excel General
    Replies: 1
    Last Post: 04-07-2006, 03:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1