Hi,

I'm struggeling with a problem in regards to my HTML editor.
I have created a seperat table editor, in which I would like to edit the tables from the HTML editor.

When selecting a table from the HTML editor, I want to retrieve THIS table element only, with all its properties and data. The table will then be handled elsewhere.

My problem is to get the table element which is curently selected.

Currently I use a code like this:
IHTMLDocument2* pHtmlDoc = NULL;
IHTMLSelectionObject* pSelection = NULL;
IHTMLElement* pElement = NULL;

hr = pHtmlDoc->get_selection(&pSelection);
if(SUCCEEDED(hr) && pSelection)
{
IDispatch* pTextRangeDisp;
hr = pSelection->createRange(&pTextRangeDisp);

if(SUCCEEDED(hr) && pTextRangeDisp)
{

IHTMLTxtRange* pRange;
hr = pTextRangeDisp->QueryInterface(IID_IHTMLTxtRange, (void**)&pRange);

if(SUCCEEDED(hr) && pRange)
{
pRange->get_htmlText(&bstr);
pRange->parentElement(&pElement);
pElement->get_innerHTML(&innerHTML);
pElement->get_outerHTML(&bstr);

pRange->Release();
}
pTextRangeDisp->Release();
}
pSelection->Release();
}

This code is not satisfactory as it picks a text selection from the HTML editor and I get the table element from here.

How can I get hold of the selcted <TABLE> element directly in any other way??

Thanks in advance!

Regards
Kjetil