We insert and link pictures (insert picture from file .emf) in our Word documents (.docx). Our documents and the graphic files are stored on our network drives. We then provide our documents to the authors to be worked on. The pictures in the documents are useful for the authors.
How do I programmatically and globally (document wise, not batch processing documents): Extract the filename (without the file extension) of the pictures linked and inserted?
We have a tool that exports the Word document .docx to .XML.
Ps: I googled for possible/potential VBA solutions. So far, I gather:
- there’s no way one can be sure / check that the pictures have been linked and inserted properly / correctly in a .docx
- there’s no way to view the source code (? at least I tried Alt+ F9 / Shift+F9)
Or is macro/ vba not the way to go?
Specs: Word 2013. 64 bit Graphic format. Emf Graphic and word documents store on a network drive Graphics not inserted and linked via the INCLUDEPICTURE field.
Graphics formatted with text wrappping fall into the
Shapescollection. These cannot useIncludePictureto manage the link - they "live" in a different layer of the document than text and field codes. So the only way to access or manage this information is through the object model (VBA, for example), or through the Word Open XML.The object model provides the
LinkFormatproperty for theShapeobject to query and manage link information. Among other things, there are properties and methods for breaking the link, getting the file name, the file path and the complete file information.The following loops all
Shapeobjects in the main body of the document and tests whether the type is a linked picture. If it is, the full file information is assigned tosSource.