Question

J'écris une DLL qui parle à Excel via son interface IDispatch. De VBA je passe dans une variante contenant Application.Caller dont je tire le pointeur IDispatch via .pDispVal.

Ce que je voudrais savoir est comment interroger l'interface via ce pointeur IDispatch. Je veux mettre en place un conteneur de point de connexion, et de trouver là un point de connexion à Excel. Le but ultime est de lier les choses à l'événement Calculer Excel et être en mesure de manipuler les données Excel.

Était-ce utile?

La solution

I would recommend Binh Ly's timelessly excellent (Delphi) COM tutorials at http://www.techvanguards.com/ which includes chapters entirely dedicated to IConnectionPoint and related mechanisms.

He also offers a free tool for generating EventSink code.

Still, I have a strong feeling that this shouldn't be necessary at all if all you want to do is react to an event triggered by the Excel Application object. Have you tried simply using the wrapper objects that the Delphi Type Library importer generates for you? You can of course also write your own wrappers.

Then again, I haven't actually written any addins for Excel yet - but I do write addins for Outlook and Word for a living and Excel really shouldn't be much different in this regard.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top