The HTMLElementEvents2 interface appears to be supported by
"non-functional" elements such as SPAN, DIV, P. See
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/events/events.asp
for other interfaces - such as HTMLAnchorEvents.

ie.document.all.each { |element|
    if element.tagName == 'A'            
        ev = WIN32OLE_EVENT.new(element, 'HTMLAnchorEvents')
        ev.on_event {|*args|
            p args
        }
    end
}

"Will Gwaltney" <will.gwaltney / sas.com> wrote in message news:<ck13hq$fog$1 / license1.unx.sas.com>...
> I'm using WIN32OLE_EVENT to set up some event handlers on various DHTML
> elements in Internet Explorer, and I'm having a bit of trouble identifying
> the right event dispinterfaces to use.  The Microsoft online documentation
> is less than helpful; they claim that you can use the HTMLElementEvents2
> interface on most all the HTML elements you care about, but I'm getting the
> following when I try:
> 
> interface not found
>     HRESULT error code:0x80004002
>       No such interface supported
> 
> Here's a code skeleton that outlines what I'm trying to do:
> 
> ---------------- (snip) -----------------------
> 
> require 'win32ole'
> 
> ie = WIN32OLE.new('InternetExplorer.Application')
> 
>      .
>      .
>      .
>  insert code to display a web page here...
>      .
>      .
>      .
> 
> elements =  ie.document.all
> elements.each do |element|
>      ev = WIN32OLE_EVENT.new(element, 'HTMLElementEvents2')
>       .
>       .
>       .
>      assign event handlers here
>       .
>       .
>       .
> end
> 
> ---------------- (snip) -----------------------
> 
> And here's the URL for the Microsoft documentation that makes the claims
> about the HTMLElementEvents2 interface:
> http://msdn.microsoft.com/workshop/browser/mshtml/tutorials/sink.asp
> 
> What am I missing?  Do I have to somehow massage the element into a
> different object that will handle the HTMLElementEvents2 interface?  Or
> should I be using another interface entirely?  (BTW, is there any way in
> WIN32OLE to figure out which interfaces an object supports?)
> 
> Any help will be much appreciated!
> 
> Will Gwaltney
> SAS Institute