Prevent error text appearing in Mail Merge when there is no image to display

给你一囗甜甜゛ 提交于 2019-12-12 02:57:43

问题


I have a document that uses mail merge to display images that are retrieved as URLs from a spreadsheet pointing to the image and the code works well.

{ INCLUDEPICTURE "{ IF TRUE { MERGEFIELD my_photo_variable_name} }" \d }

The issue I have is that when there is no image URL for the current mail merge, an error message is displayed.

Error! Filename not specified. 

I am trying to engineer the code so that it just leaves the mail merge field blank like it does for text fields rather than display the error message.

I tried tried using an IF clause to determine if there is an image:

{IF { INCLUDEPICTURE "{ IF TRUE { MERGEFIELD my_photo_variable_name} }" \d }}

but that didn't work so I tried using another IF clause determine if the variable was a null value (no image):

{IF {{MERGEFIELD my_photo_variable_name} <> ""}{ INCLUDEPICTURE "{ IF TRUE {{MERGEFIELD my_photo_variable_name}  " \d }}

Both of these attempts do not even show the error message let alone the image. Anyone know a way around this or am I stuck with an error message?


回答1:


Turns out I was very close, incorrect curly bracket placement was what was causing my attempt to fail:

{IF {MERGEFIELD my_photo_variable_name} <> "" {INCLUDEPICTURE "{IF TRUE {MERGEFIELD my_photo_variable_name}}" \d} "Text to display if no picture available"}

Which translates as:

If there is no value for the image my_photo_variable_name, include the image in the mail merge.

If there is no value i.e no image, then display custom text Text to display if no picture available.



来源:https://stackoverflow.com/questions/34902692/prevent-error-text-appearing-in-mail-merge-when-there-is-no-image-to-display

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!