'Extract OLE object data in Microsoft Office without OLE application
Is it possible to extract the content of an embedded OLE object in Microsoft Office using VBA/VSTO? I am talking about a situation where the application with which the OLE object was created is not available. In this case some sort of converter application could make use of the raw data.
For instance, in Excel the object is accessible via ActiveSheet.Shapes(x).OLEFormat but I have not found a way to retrieve the raw data of the object.
One way would be to open the native file (Office Open XML/Compound File) and extract the data from there. But maybe there is a simpler approach?
Solution 1:[1]
Copy the OLEObject to the clipboard, then get it over "Shell.Application" (verb Paste) from the clipboard to folder
For Each Sh In Sheet1.OLEObjects
If InStr(1, Sh.Name, "Object", 1) Then
Sh.Copy
' this code paste Embedded Object to folder
CreateObject("Shell.Application").Namespace("c:\temp\!").Self.InvokeVerb "Paste"
End If
Next Sh
Solution 2:[2]
I approached this another way (non-VBA).
- Rename the document/spreadsheet to .zip (eg instead of .docx)
- Open the .zip and browse the structure to the embedded objects eg \word\embeddings

- Edit the .bin file(s) (eg in Notepad++) - you should be able to identify the file extension in the first 10 lines

- Now strip all the header/junk from the start of the file - search for
ÐÏࡱand remove everything before/above it
- The beginning of the file will now look like this:
- Save the file with the extension that you identified above
- The file should open and function correctly
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | onit |
| Solution 2 |


