Accessing the underlying OLE data

A

abhimanyu

I am creating an AddIn for Excel 2002+ using C# 2005.
I can access the OLEObject within Excel using interop but I dont know
how can I access the data inside it ("Native"). I tried using
OLEObject::Copy() and then using OleOpenClipboard() to get
IDataObject
pointer and it worked. But I don;t want to use clipboard during this
operation

this is what I did :

///////////////////////////////////////////////////////////////////////////­///////////////////////////////////////////////////////////////////////////­/////////////
Guid guidDataObject = new Guid("0000010E-0000-0000-
C000-000000000046"); // Guid for IDataObject
IntPtr pUnknown = Marshal.GetIUnknownForObject(oleObject);

IntPtr pDataObject = IntPtr.Zero;
int hr = Marshal.QueryInterface(pUnknown, ref guidDataObject, out
pDataObject);
///////////////////////////////////////////////////////////////////////////­///////////////////////////////////////////////////////////////////////////­/////////////

But the HRESULT says "Specified cast is not valid"
I also tried using OleRun() before QueryInterface(...), but it didnt
work.


thanks
 

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