How to find the files linked (OLE) within a Word Document?
Posted on 2006-07-02
I have a requirement to read a range of OLE Compound File formats (including Word Documents, Excel, Powerpoint, etc) and perform the following tasks;
1) Extract a list of all files either linked or embedded to the parent document
2) Save these linked files to a specific location (or in the case of linked files, can just copy the link target to a new location)
My problem here is really in Step 1 -> I have so far been unable to find a way to access linked/embedded files within a parent document.
My current methodology is something like;
1) Call StgOpenStorageEx on the parent file and receive an IStorage pointer
2) Call StgIsStorageFile to make sure I am working with a compound storage file
3) Call IStorage->EnumElements to find the nested objects
4) Check the type of each object looking for contained STGTY_STORAGE objects
5) Try to get an IOleLink pointer from that storage?
Here is about where it falls down. No idea if my steps thus far are correct, but I can't get an IOleLink pointer on any of the enumerated objects...