2009. március 23., hétfő

How to map a variant OLEObject to an interface


There seems to be no way to map the variant OLEObject to an interface (in our case Word 2000) or even cast it so at design time.


Yes there is. The OleContainer's OleObject property holds the document as an IDispatch, and you can just cast to the interface you want. For example:

{ ... }
Doc: _Document;
{ ... }

OleContainer1.CreateObjectFromFile(Path, False);
Doc := IDispatch(OleContainer1.OleObject) as _Document;

Nincsenek megjegyzések:

Megjegyzés küldése