ContentControl Picture data

G

Greg Maxey

Does anyone know if there is any accessible data about the image file
displayed in a image type ContentControl?

I am trying to export data from a collection of ContentControls in one
(master) document to a like collection of controls in a second (slave)
document. The text Content Controls are easy enough, but all I have found
to work with the image CCs is to copy the image in the master CC and then
paste into the slave CC. This works, but unfortunately it results in the
different size CC (image is reproduced true, but the CC handles extend
across the entire page). If the CC is located in the middle of a line it is
forced to the next complete line.

Sub Testing()
'Simply set the text of the slave to that of the master
Documents("Document2").ContentControls(1).Range.Text =
Documents("Document1").ContentControls(1).Range.Text
'I have to copy then paste the image CCs
Documents("Document1").ContentControls(2).Copy
Documents("Document2").ContentControls(2).Range.Paste
End Sub

If I could access data about the image (e.g., file name) in the master CC
then is seems like I should be able to set that data in the slave CC to
obtain an exact copy of the master CC.

Thanks.
 
P

Peter Jamieson

I haven't looked in detail but if there's a picture in the control you
can do e.g.

Sub getccpicinfo()
Dim objCC As Word.ContentControl
Dim rngCC As Word.Range
Dim shpCC As Word.InlineShape
For Each objCC In ActiveDocument.ContentControls
If objCC.Type = wdContentControlPicture Then
Set rngCC = objCC.Range
Set shpCC = rngCC.InlineShapes(1)
Debug.Print shpCC.Height
' etc. I don't think the picture's pathname is in there though
Set shpCC = Nothing
Set rngCC = Nothing
End If
Next

End Sub

Peter Jamieson

http://tips.pjmsn.me.uk
 

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