2 Quick Ways to Extract the MS Office Files Embedded in Your Word Document

In today’s article, we will provide you with 2 quick ways to extract all the MS office files embedded in your Word document.

Every so often, we could inherit a Word document containing multiple embedded files, such as below:Word Document with Embedded Files

Normally, to export them, we will have to open the file and then save it. This way, however, is acceptable when there are few files. Once a large number of objects are involved, we shall look for some more quick and energy-saving shortcuts. For this reason, we have the following 2 methods ready for you.

Method 1: Change the File Extension

  1. First off, before anything else, we recommend you to make a copy of the target file, in case any incidents may cause damage to it.
  2. Secondly, right click on the document icon and choose “Rename” on the menu.
  3. Thirdly, change the extension “.docx” to “.zip”.
  4. You will encounter with the warning message, and just click “Yes”.Click "Yes" to Change File Extension
  5. After the document converting to a zip file, double click to open it.
  6. Now double click to open “word” folder.
  7. Then double click to open “embeddings” folder. You can find all files there but without identifiable. The mess is you have to rename them.Extract Embedded Files without Identifiable Names

Method 2: Run Word Macro

  1. First and foremost, click on “Developer” tab and then the “Visual Basic”. Or just press “Alt+ F11” instead if the “Developer” tab isn’t available.Click "Developer"->Click "Visual Basic"
  2. Next click “Normal” project.
  3. Then click “Insert” tab.
  4. Choose “Module” on the drop-down menu.Click "Normal"->Click "Insert"->Click "Module"
  5. Now double click on the new module to have the coding space.
  6. And paste the bellowing codes there:
Sub ExtractAndSaveEmbeddedFiles()
  Dim objEmbeddedShape As InlineShape
  Dim strShapeType As String, strEmbeddedDocName As String
  Dim objEmbeddedDoc As Object
 
  With ActiveDocument
  For Each objEmbeddedShape In .InlineShapes
 
  '  Find and open the embedded doc.
  strShapeType = objEmbeddedShape.OLEFormat.ClassType
  objEmbeddedShape.OLEFormat.Open
 
  '  Initialization
  Set objEmbeddedDoc = objEmbeddedShape.OLEFormat.Object
 
  '  Save embedded files with names as same as those of icon label. 
  strEmbeddedDocName = objEmbeddedShape.OLEFormat.IconLabel
  objEmbeddedDoc.SaveAs "C:\Users\Public\Documents\New folder\" & strEmbeddedDocName
  objEmbeddedDoc.Close
 
  Set objEmbeddedDoc = Nothing
 
  Next objEmbeddedShape
  End With
End Sub
  1. Finally, click “Run” button or hit “F5”.Paste Codes->Click "Run"

All embedded files will be stored under a specific directory with their original names.Files with Identifiable Names

Note:

In code line “objEmbeddedDoc.SaveAs “C:\Users\Public\Documents\New folder\” & strEmbeddedDocName”, the “C:\Users\Public\Documents\New folder\” is the location for storing files. Remember to replace it with an actual one.

Take Care of Word Files

Since some of you work with Word very frequently, then confronting with a corrupted Word can be commonplace. Therefore, that’s why we lay much emphasis on well handling files. After all, once a file gets damaged, it takes both time and money to bring it back to life.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including fixing damaged Excel and pdf repair software products. For more information visit www.datanumen.com

11 responses to “2 Quick Ways to Extract the MS Office Files Embedded in Your Word Document”

  1. Hurrah, that’s what I was seeking for, what a data! existing here at this blog, thanks admin of this site.

  2. Solution 2 worked fine for me.
    81 files extrated in less than 3 minutes.

    Thank you Vera Chen and DataNumen, really good job!

  3. put On Error Resume Next to the For Each cycle

    Sub ExtractAndSaveEmbeddedFiles()
    Dim objEmbeddedShape As InlineShape
    Dim strShapeType As String, strEmbeddedDocName As String
    Dim objEmbeddedDoc As Object

    With ActiveDocument
    For Each objEmbeddedShape In .InlineShapes
    On Error Resume Next
    ‘ Find and open the embedded doc.
    strShapeType = objEmbeddedShape.OLEFormat.ClassType
    objEmbeddedShape.OLEFormat.Open

    ‘ Initialization
    Set objEmbeddedDoc = objEmbeddedShape.OLEFormat.Object

    ‘ Save embedded files with names as same as those of icon label.
    strEmbeddedDocName = objEmbeddedShape.OLEFormat.IconLabel
    objEmbeddedDoc.SaveAs “C:\Users\Public\Documents\New folder\” & strEmbeddedDocName & “.pdf” ‘Add this extension
    objEmbeddedDoc.Close

    Set objEmbeddedDoc = Nothing

    Next objEmbeddedShape
    End With
    End Sub

  4. Thank you for the CODE. To make it extract PDF, you need to modify little bit.

    Sub ExtractAndSaveEmbeddedFiles()
    Dim objEmbeddedShape As InlineShape
    Dim strShapeType As String, strEmbeddedDocName As String
    Dim objEmbeddedDoc As Object

    On Error Resume Next ‘ Add this
    With ActiveDocument
    For Each objEmbeddedShape In .InlineShapes

    ‘ Find and open the embedded doc.
    strShapeType = objEmbeddedShape.OLEFormat.ClassType
    objEmbeddedShape.OLEFormat.Open

    ‘ Initialization
    Set objEmbeddedDoc = objEmbeddedShape.OLEFormat.Object

    ‘ Save embedded files with names as same as those of icon label.
    strEmbeddedDocName = objEmbeddedShape.OLEFormat.IconLabel
    objEmbeddedDoc.SaveAs “C:\Users\Public\Documents\New folder\” & strEmbeddedDocName & “.pdf” ‘Add this extension
    objEmbeddedDoc.Close

    Set objEmbeddedDoc = Nothing

    Next objEmbeddedShape
    End With
    End Sub

  5. The code in the method 2 worked very well for me on one agenda with embedded documents related to each agenda. However, the embedded documents on a different agenda were of a different type, still word documents but which did not get recognize by: ObjEmbeddedShape and thus it does not execute the saveas command. Is thee a different type of embedment?

  6. Martin, from my experience, you cannot extract PDF files – however this will work for Excel files.

  7. The method 1 is better. Save the .doc file with the latest version .docx file and then, change the extension to .zip. So it work for me and it is easy.

  8. I’ve tried the Method 2, however, It doesn’t work for me. When I run the macro it returns the error 430: “Class does not support automation or does not supported expected interface.” Is there any solution for that?

Leave a Reply

Your email address will not be published. Required fields are marked *