How to conditionally print a picture in Word?

R

Randy S

I'm looking to apply a condition to the appearance of a picture.
Alternatively, maybe I can dynamically format the picture so it does not show
based on a condition.
 
J

Jay Freedman

Randy said:
I'm looking to apply a condition to the appearance of a picture.
Alternatively, maybe I can dynamically format the picture so it does
not show based on a condition.

You don't need a macro for this. Create a custom document property (in File
Properties > Custom), let's say you call the property ShowPic. Let's
assume you make it a Number type and give it the value 1.

In the body of the document, insert an IF field inside which you nest (using
Ctrl+F9 to create the field braces) a DocProperty field:

{ IF {DocProperty ShowPic} = 1 [picture] }

Where I've shown [picture], paste in the picture itself.

When you update the field, the picture will appear.

If you now go back to the File > Properties dialog and change the value of
the ShowPic property to anything else, say 0, then update the field again,
the picture will disappear. Put the property value back to 1, update the
field, and the picture reappears.

There are other ways to do this, such as using a DocVariable field with a
document variable (which is accessible only from VBA), or using a Ref field
with the value of a bookmark, possibly one that's set by an ASK field. You
can even make it conditional on the value of a DATE field -- for example, if
the field is

{IF {DATE \@ DDDD} = "Tuesday" [picture]}

then the picture will appear on Tuesdays and be invisible on other days. I
don't know what you'd use that for, but Word can do it. :)

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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