Link to home
Start Free TrialLog in
Avatar of Bryce Bassett
Bryce BassettFlag for United States of America

asked on

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

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!
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bryce Bassett

ASKER

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?
Avatar of Bill Prew
Bill Prew

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
Bill, thanks for your help!
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.