Solved

How to find the files linked (OLE) within a Word Document?

Posted on 2006-07-02
7
955 Views
Last Modified: 2008-01-09
Hi,

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...

?
0
Comment
Question by:rjlohan
  • 4
  • 3
7 Comments
 
LVL 11

Expert Comment

by:KurtVon
Comment Utility
I think the problem you are having is simply that Word stores the OLE links in a record within the storage object, not as a storage object.  I can't help much with parsing those, but this might: http://64.233.161.104/search?q=cache:Lyjp4eU4rLYJ:www.codeproject.com/macro/ssfview.asp+STGTY_STORAGE+Word&hl=en&gl=us&ct=clnk&cd=2&client=firefox-a

Hope this helps.
0
 
LVL 11

Accepted Solution

by:
KurtVon earned 500 total points
Comment Utility
I think you will find the information you need in the "ObjectPool" storage item.
0
 

Author Comment

by:rjlohan
Comment Utility
That looks to be right - if I call OpenStorage on the 'ObjectPool' storage item, the sub-storages of that appear to be the actual linked items, and have storage class IDs such as {CLSID_StdOleLink} or {CLSID_Microsoft Word Document}.

Just wish I could find some documentation to be sure! :-P

Cheers,
Ryan
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 11

Expert Comment

by:KurtVon
Comment Utility
I know that Word uses the object pool to create the OLE objects it links to, but I suspect documentation is going to be hard to come by just because Microsoft guards that like a state secret.
0
 

Author Comment

by:rjlohan
Comment Utility
It certainly looks that way. I have found how to access some link types, where the sub-storage within the ObjectPool has a classID of 'CLSID_StdOleLink', but accessing other embedded content, say a Word Document embedded as 'CLSID_Microsoft Word Document' is proving quite difficult. Can't find any information about the original link file (such as paths) within the storage anywhere.
0
 
LVL 11

Expert Comment

by:KurtVon
Comment Utility
If I remember correctly, Word doesn't use a path, but a UUID for the location of the document.  The OS (2000 and later) tracks the UUID for the location, so renaming or moving the file keeps the UUID the same, and links are much harder to break.  Try passing UUIDs inside the object to directory services to see if any produce links.
0
 

Author Comment

by:rjlohan
Comment Utility
Can't see anywhere to find that UUID. There must be a way, Word obviously knows how to do certain things, like opening these files...
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now