Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OLE Automation how does it work???

Status
Not open for further replies.

jayjay60

Programmer
Jun 19, 2001
97
FR
I would like to create a sort of library of method in vc++ to be used in excel. So i believe that if i create a .dll application instead of a .exe, i would be better. But i have read that i could use especially OLE Automation for that kind of application. I have read in msdn the comexcel sample, but it's not really what i want to do.

In fact, i would like that the methods defined in first in vc++ could be used in excel as we could to simply when we create functions in vba. So how we could do that? Where could i find samples?

thanks in advance for your answers.

jayjay
 
The easiest way to do this is to create an ATL dll project. Then insert a simple object into the project, set the interface type to dual and the threading model to single or apartment. When the dll is compiled and registered, you can create an instance of the object in VBA with the command

dim oThing as Object
oThing = CreateObject(&quot;<progid>&quot;)

where <progid> is the ProgID that you set for the object. The methods of the object must only use automation types like BSTR, VARIANT, SAFEARRAY, and LPDISPATCH. To have a method return a value. All methods must return HRESULT, which is not the return value you see in VBA. To define a return value for VBA, and an argument to the method that has the attribute [out, retval].


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top