How to determine whether a Word picture content control contains an image?

Bryce Bassett
Bryce Bassett used Ask the Experts™
on
How do I determine programmatically whether a Word picture content control if filled (has a picture added by the user) or empty?  I've seen the suggestion to use

if mycc.range.inlineshapes.count>0 then  'it has a picture

Open in new window

However, the blue placeholder with the clickable image that Word uses to signal a picture CC is itself an inline shape, so even if the user has not inserted a picture you still get count = 1!  So this does not answer the question.

Any help would be appreciated!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Test your restores, not your backups...
Top Expert 2016
Commented:
I poked around at this for a while and unfortunately I don't see a way to determine what you seek.  It appears to me that when the CC is first added it does indeed "contain" an image as a placeholder as you observed.  This gets replaced when a true image is placed in the CC.  I couldn't find any properties of the CC object that would allow this distinction to be noted.  Naturally images are different and so some of the properties do change, but nothing that would make sense as a flag to indicate if this is just containing the default placeholder image, or a real image.

Sorry to say, but I'm not seeing a way to get what you need here...


»bp
Bryce BassettFreelance VBA programmer

Author

Commented:
Thanks, Bill.  That's what I was afraid of.    

I came up with this workaround just now:  I use a checkmark to set the "Remove content control when contents are edited" property.  Then when the user replaces the placeholder with a real picture, the CC goes away.  That way, my macro can identify the empty picture CCs that have not been filled.

Any other suggestions?
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
If that meets your needs then go with it.

What problem were you trying to solve.  In this approach I think the user could still insert a picture, causing the CC to be removed and the inline image left.  But then they could then delete the inline image, and you would still be left with a doc that they did not add an image to, was that what you were trying to prevent?


»bp
Bryce BassettFreelance VBA programmer

Author

Commented:
Bill, thanks for your help!
Bryce BassettFreelance VBA programmer

Author

Commented:
The problem I was solving:  I have a template with 10 picture Content Controls.  The user fills in some of the pictures, but they may leave some blank.  If they don't fill in a given picture, we wanted to remove those CCs.  Since there is no property to tell us the CC has been filled with a picture by the user, and since the placeholder looks to VBA like a picture, I remove the content control upon editing.  That way, my program can iterate the content controls in the document, and any named "Map" (I've pre-named them all that) gets deleted.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial