Can't get IHtmlElement on an IHTMLElementCollection item



I've got some code that's been working fine until a couple of days ago.



I'm doing a QueryInterface for IHtmlElement on an IDispatch that I retrieve
from an IHtmlElementCollection, but it's failing with E_NO_INTERFACE.



If I QI for IHtmlElement2 (or 3 and 4) it works fine, but I can't get
IHtmlElement. I can't do what I need without IHtmlElement, i.e. getting and
setting the element attributes.



This is pseudo-code with error checking removed that shows how I'm getting
to the failure.



CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2, (void**)&m_spHtmlDocument2);

// Code put to the object into design mode and load the HTML removed

CComPtr<IHTMLElementCollection> spImages;

m_spHtmlDocument2->get_images(&spImages);

CComVariant item(0);

CComPtr<IDispatch> spDispatch;

spImages->item(item, item, &spDispatch);

CComQIPtr<IHTMLElement> spElement(spDispatch);



The last call fails with E_NO_INTERFACE.



As I say, this used to work when I wrote the code, so I guess something has
updated a COM component on my machine since then. I have another test
machine on which it is still working.



Any help appreciated

JF




.