Copy OLE object from Clipboard

  • Thread starter Ludwig Wittgenstein
  • Start date
L

Ludwig Wittgenstein

Hi, all.

Here's the scenario: I embedd a .txt file in Word as OLE object,
then I copy it (manually), so now it's on the clipboard. How do I
programatically (in C#) get that OLE object file from the clipboard
and dump it into an actual text file on the file system? All I would
like to know is how to grab the OLE from the clipboard and transform
it into a file, stream, string, or anything that gives me the internal
contents of that txt file.

Thanks in advance,
 
O

Oliver Sturm

Hello Ludwig,
Here's the scenario: I embedd a .txt file in Word as OLE object,
then I copy it (manually), so now it's on the clipboard. How do I
programatically (in C#) get that OLE object file from the clipboard
and dump it into an actual text file on the file system? All I would
like to know is how to grab the OLE from the clipboard and transform
it into a file, stream, string, or anything that gives me the internal
contents of that txt file.

I think you'll have to use the OLE interfaces to do this - IDataObject
seems to come to mind. With this type of content, the statement "[the file
is] now on the clipboard" is not correct, as the clipboard only contains
information about the file, not the file itself. To get to the actual
content in a certain representation, you have to communication with the
application that's the source of the clipboard operation, and to do that
you have to use the OLE interfaces.

I'm not aware of any existing .NET code to help you, but you may well find
some on sites like CodeProject. Otherwise dig out a copy of Inside OLE 2
and hack away... <g>


Oliver Sturm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top